在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隊列中結束以供以後調查?
謝謝