Freigeben über


Service Bus Brokered Messaging: Unexpected Error Sending Messages Larger than 256K

When sending a message to a Azure Service Bus Brokered message queue or topic, with the .Net client library (Microsoft.ServiceBus.dll) and, the size of the message exceeds 256KB (current max message size documented under Windows Azure Service Bus Quotas), you will see the below error. The same error reoccurs when attempting to resend the message.

 

Microsoft.ServiceBus.Messaging.MessagingCommunicationException was unhandled

  HResult=-2146233088

  Message=Error during communication with Service Bus. Check the connection information, then retry.

  Source=Microsoft.ServiceBus

  IsTransient=true

  StackTrace:

       at Microsoft.ServiceBus.Common.ExceptionDispatcher.Throw(Exception exception)

       at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)

       at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.RunSynchronously()

       at Microsoft.ServiceBus.Messaging.MessageSender.OnSend(TrackingContext trackingContext, IEnumerable`1 messages, TimeSpan timeout)

       at Microsoft.ServiceBus.Messaging.MessageSender.Send(TrackingContext trackingContext, IEnumerable`1 messages, TimeSpan timeout)

       at Microsoft.ServiceBus.Messaging.MessageSender.Send(BrokeredMessage message)

       at Microsoft.ServiceBus.Messaging.QueueClient.Send(BrokeredMessage message)

       at repro.Program.Main(String[] args)

       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)

       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)

       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)

       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

       at System.Threading.ThreadHelper.ThreadStart()

  InnerException: System.ServiceModel.CommunicationObjectFaultedException

       HResult=-2146233087

       Message=Internal Server Error: The server did not provide a meaningful reply; this might be caused by a premature session shutdown..TrackingId:52a267de-d987-4b31-b86f-4ee7bb9de012, Timestamp:11/7/2013 3:27:02 AM

       Source=Microsoft.ServiceBus

  StackTrace:

         Server stack trace:

         Exception rethrown at [0]:

            at Microsoft.ServiceBus.Common.ExceptionDispatcher.Throw(Exception exception)

            at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)

            at Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.DuplexCorrelationAsyncResult.End(IAsyncResult result)

            at Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.EndRequest(IAsyncResult result)

            at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.RequestAsyncResult.<GetAsyncSteps>b__4(RequestAsyncResult thisPtr, IAsyncResult r)

            at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)

         Exception rethrown at [1]:

            at Microsoft.ServiceBus.Common.ExceptionDispatcher.Throw(Exception exception)

            at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)

            at Microsoft.ServiceBus.Common.AsyncResult`1.End(IAsyncResult asyncResult)

            at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.EndRequest(IAsyncResult result)

            at Microsoft.ServiceBus.Messaging.Sbmp.RedirectBindingElement.RedirectContainerChannelFactory`1.RedirectContainerSessionChannel.RequestAsyncResult.<>c__DisplayClass17.<GetAsyncSteps>b__a(RequestAsyncResult thisPtr, IAsyncResult r)

            at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)

         Exception rethrown at [2]:

            at Microsoft.ServiceBus.Common.ExceptionDispatcher.Throw(Exception exception)

            at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)

            at Microsoft.ServiceBus.Common.AsyncResult`1.End(IAsyncResult asyncResult)

            at Microsoft.ServiceBus.Messaging.Sbmp.RedirectBindingElement.RedirectContainerChannelFactory`1.RedirectContainerSessionChannel.EndRequest(IAsyncResult result)

            at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.RequestAsyncResult.<GetAsyncSteps>b__4(RequestAsyncResult thisPtr, IAsyncResult r)

            at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)

         Exception rethrown at [3]:

            at Microsoft.ServiceBus.Common.ExceptionDispatcher.Throw(Exception exception)

            at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)

            at Microsoft.ServiceBus.Common.AsyncResult`1.End(IAsyncResult asyncResult)

            at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.EndRequest(IAsyncResult result)

            at Microsoft.ServiceBus.Messaging.Sbmp.SbmpTransactionalAsyncResult`1.<GetAsyncSteps>b__3b(TIteratorAsyncResult thisPtr, IAsyncResult a)

            at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)

         Exception rethrown at [4]:

            at Microsoft.ServiceBus.Common.ExceptionDispatcher.Throw(Exception exception)

            at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)

            at Microsoft.ServiceBus.Common.AsyncResult`1.End(IAsyncResult asyncResult)

            at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.EndSendCommand(IAsyncResult result)

       InnerException:

 The above errors results since the Service Bus service endpoint the Brokered Messaging client talks to, is configured to support a maximum messages size of 256KB.

To protect against this error it is recommend to check the size of the message prior to sending it to Service Bus. Note BrokeredMessage.Size property is only accurate after a Send operation. This is because the size that is checked is the size of the wire message and not the size of the Object type serialized into BrokeredMessage. Since we cannot calculate the underlying the wire message size prior to sending, ensure your object size slightly less the 256KB – 250KB is recommended.