在Azure服务总线中,我希望发送消息失败,并且没有定义任何订阅。我通过将EnableFilteringMessagesBeforePublishing
设置为true
来实现此目标,这会引发异常NoMatchingSubscriptionException
。在发送到Azure服务总线中的主题时DeadLettering BrokeredMessages
现在,在处理这个异常时,我想DeadLetter它。如果我把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();
}
这意味着,可以将消息DeadLetter'ed只接收其时,而不是在发送。
上述假设是否正确?
在任何情况下,处理失败消息发送的最佳策略是什么?发送过程中是否有失败的消息方式可以在DeadLetter队列中结束以供以后调查?
谢谢