【发布时间】:2017-03-30 12:53:02
【问题描述】:
在 Azure 服务总线中,我希望消息发送失败,但没有定义订阅。我通过将EnableFilteringMessagesBeforePublishing 设置为true 来实现这一点,这会引发异常NoMatchingSubscriptionException。
现在,在处理此异常时,我想对其进行死信处理。如果我打电话给BrokeredMessage.DeadLetter(),它会抛出InvalidOperation 并带有消息'ReceiveContext is null'
try
{
await topicClient.SendAsync(brokeredMessage);
}
catch (NoMatchingSubscriptionException ex)
{
// **throws exception** if message is attempted to move to DeadLetter queue
await brokeredMessage.DeadLetterAsync();
}
这意味着消息只能在接收时被死信,而不是在发送时。
上述假设正确吗?
无论如何,处理失败消息发送的最佳策略是什么?发送失败的消息有没有办法最终进入死信队列以供日后调查?
谢谢
【问题讨论】:
标签: azure azureservicebus