Azure 服务总线出现间歇性问题。偶尔,在总线上放置消息会导致以下异常:
类型:无效操作异常
MESSAGE:无法执行操作,因为代理消息“723eab13dab34351a78bb687d0923b89”已被消费。请使用新的 BrokeredMessage 实例进行操作。
堆栈跟踪
at Microsoft.ServiceBus.Messaging.MessagingUtilities.ValidateAndSetConsumedMessages(IEnumerable`1 messages)
at Microsoft.ServiceBus.Messaging.MessageSender.Send(TrackingContext trackingContext, IEnumerable`1 messages, TimeSpan timeout)
at Microsoft.Practices.TransientFaultHandling.RetryPolicy.<>c__DisplayClass1.<ExecuteAction>b__0()
at Microsoft.Practices.TransientFaultHandling.RetryPolicy.ExecuteAction[TResult](Func`1 func)
at IQ.IR.Core.ServiceBus.AzureBus`1.Enqueue(T message) in c:\BuildAgent\work\cc0c51104c02a4e9\IQ.IR.Core\ServiceBus\AzureBus.cs:line 69
...Rest of stacktrace snipped as it's within my app
AzureBus 的违规代码是:
public void Enqueue(T message)
{
using (var brokeredMessage = new BrokeredMessage(message) { Label = message.GetType().FullName, TimeToLive = _timeToLive })
{
_retryPolicy.ExecuteAction(() => _sender.Send(brokeredMessage));
}
}
传入的 T 消息是
[Serializable]
public class ValidationMessage
{
public string ValidationToken { get; set;}
}
_retryPolicy 是一个
RetryPolicy<ServiceBusTransientErrorDetectionStrategy>
_timeToLive 是 12 小时的时间跨度
有任何想法吗?