2017-06-06 72 views
0

我收到OperationCanceledException当我发送消息到主题队列(我正在从Azure函数内运行我的代码)。 我使用的版本是:“WindowsAzure.ServiceBus”:“4.1.1”(最新) 当我进行负载测试时意味着许多消息正在此服务总线中发送(包含多个主题)。 我被告知使用重试机制为:OperationCanceledException当发送到服务总线

client.RetryPolicy = new RetryExponential(minBackoff: TimeSpan.FromSeconds(0.1), 
              maxBackoff: TimeSpan.FromSeconds(30), 
              maxRetryCount: 3); 

但我认为这已经在默认情况下完成的,不是吗?

会在这里适当的帮助 - 为什么我得到这个例外,我能做些什么来解决这个问题?

这里是个例外:

Exception System.OperationCanceledException: The operation cannot be performed because the entity has been closed or aborted. ---> System.ServiceModel.CommunicationObjectAbortedException: Internal Server Error: The server did not provide a meaningful reply; this might be caused by a premature session shutdown. TrackingId:88386cb1-a4e6-42e2-a8e1-bad3a2403329, Timestamp:6/6/2017 7:55:23 AM 
    at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result) 
    at Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.EndRequest(IAsyncResult result) 
    at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.RequestAsyncResult.<>c.<GetAsyncSteps>b__9_3(RequestAsyncResult thisPtr, IAsyncResult r) 
    at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result) 
--- End of stack trace from previous location where exception was thrown --- 
    at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result) 
    at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.EndRequest(IAsyncResult result) 
    at Microsoft.ServiceBus.Messaging.Sbmp.RedirectBindingElement.RedirectContainerChannelFactory`1.RedirectContainerSessionChannel.RequestAsyncResult.<>c__DisplayClass8_1.<GetAsyncSteps>b__4(RequestAsyncResult thisPtr, IAsyncResult r) 
    at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result) 
--- End of stack trace from previous location where exception was thrown --- 
    at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result) 
    at Microsoft.ServiceBus.Messaging.Sbmp.RedirectBindingElement.RedirectContainerChannelFactory`1.RedirectContainerSessionChannel.EndRequest(IAsyncResult result) 
    at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.RequestAsyncResult.<>c.<GetAsyncSteps>b__9_3(RequestAsyncResult thisPtr, IAsyncResult r) 
    at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result) 
--- End of stack trace from previous location where exception was thrown --- 
    at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result) 
    at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.EndRequest(IAsyncResult result) 
    at Microsoft.ServiceBus.Messaging.Sbmp.SbmpTransactionalAsyncResult`1.<>c.<GetAsyncSteps>b__18_3(TIteratorAsyncResult thisPtr, IAsyncResult a) 
    at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result) 
--- End of stack trace from previous location where exception was thrown --- 
    at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result) 
    at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.EndSendCommand(IAsyncResult result) 
    --- End of inner exception stack trace --- 
    at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.EndSendCommand(IAsyncResult result) 
    at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.OnEndSend(IAsyncResult result) 
    at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result) 
--- End of stack trace from previous location where exception was thrown --- 
    at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result) 
    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) 

回答

1

重试策略默认由ASB客户端启用。你不需要亲自去做。

异常你得到的是OperationCanceledException并根据文档:

Retry will not help.

这是归类为“用户编码错误”。纵观异常堆栈跟踪,这是发生在发送操作和错误是

Internal Server Error: The server did not provide a meaningful reply; this might be caused by a premature session shutdown. TrackingId:88386cb1-a4e6-42e2-a8e1-bad3a2403329...

我肯定这不是用户代码错误,但一些发生在代理端。随错误提供的TrackingId应该允许您打开Microsoft的支持案例,以至少知道该命令失败时代理发生了什么。

编辑

同时我建议将其与附加重试/退避逻辑来实现您的操作。有些东西不会在严密的循环中重试,并且不取决于客户的RetryPolicy

相关问题