Quantcast
Channel: Service Bus forum
Viewing all articles
Browse latest Browse all 1916

Cannot post to an event hub from a cloud service

$
0
0

I am trying to use an EventHubSender to send messages to an EventHub from within a cloud service.

        public async Task SendMessageAsync(T message, Dictionary<string, string> properties)
        {
            try
            {
                var eventHubSender = EventHubSender.CreateFromConnectionString(ServiceBusConnectionString);
                var serializedString = JsonConvert.SerializeObject(message);
                var data = new EventData(Encoding.UTF8.GetBytes(serializedString));

                if (properties != null)
                {
                    foreach (var property in properties)
                    {
                        data.Properties[property.Key] = property.Value;
                    }
                }
                eventHubSender.Send(data);
            }
            catch (Exception exception)
            {
                Trace.TraceError("Error while executing SendMessageAsync method : {0}",
                       ExceptionLibrary.GetExceptionDetails(exception));

                throw;
            }
        }


My send code works in a unit test environment, but throws the following exception when exercised in the cloud service.

Error while executing SendMessage method : Date Time : 4/19/2016 5:09:26 AM
Message : ProtocolName
Source : Microsoft.ServiceBus
Stack Trace : 
Server stack trace: 


Exception rethrown at [0]: 
   at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at Microsoft.ServiceBus.Messaging.Amqp.AmqpMessageSender.EndCreateLink(IAsyncResult result)
   at Microsoft.ServiceBus.Messaging.Amqp.FaultTolerantObject`1.CreateAsyncResult.<GetAsyncSteps>b__4(CreateAsyncResult thisPtr, IAsyncResult r)
   at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)

Exception rethrown at [1]: 
   at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at Microsoft.ServiceBus.Messaging.Amqp.FaultTolerantObject`1.OnEndCreateInstance(IAsyncResult asyncResult)
   at Microsoft.ServiceBus.Messaging.SingletonManager`1.EndGetInstance(IAsyncResult asyncResult)
   at Microsoft.ServiceBus.Messaging.Amqp.AmqpMessageSender.OnEndOpen(IAsyncResult result)
   at Microsoft.ServiceBus.Messaging.ClientEntity.EndOpen(IAsyncResult result)
   at Microsoft.ServiceBus.Messaging.OpenOnceManager.OnEndCreateInstance(IAsyncResult asyncResult)
   at Microsoft.ServiceBus.Messaging.SingletonManager`1.EndGetInstance(IAsyncResult asyncResult)
   at Microsoft.ServiceBus.Messaging.OpenOnceManager.OpenOnceManagerAsyncResult`1.OpenComplete(IAsyncResult result)
   at Microsoft.ServiceBus.Common.AsyncResult.AsyncCompletionWrapperCallback(IAsyncResult result)

Exception rethrown at [2]: 
   at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at Microsoft.ServiceBus.Messaging.OpenOnceManager.OpenOnceManagerAsyncResult`1.End(IAsyncResult result, T& output)
   at Microsoft.ServiceBus.Messaging.OpenOnceManager.End(IAsyncResult result)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at PopHealth.Infrastructure.MessageProcessing.EventHubManager`1.<SendMessageAsync>d__38.MoveNext() in <My Namespace>\EventHubManager.cs:line 257
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at PopHealth.Infrastructure.MessageProcessing.EventHubManager`1.<SendMessage>d__39.MoveNext() in <My Namespace>\EventHubManager.cs:line 263

Any ideas?


Viewing all articles
Browse latest Browse all 1916

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>