Azure 服务总线 - 被遗弃的消息返回给同一个订阅者

Azure Service Bus - Abandoned messages comes back to same subscriber

我正在使用具有 2 个订阅者的服务总线队列(基于触发器的流 - 比如主要和次要)。我正在使用 peek-lock 来接收消息。 如果其中一个流决定它不能处理此消息,则该流发出 abandon message in queue 步骤。 现在 MaxDeliveryCount 在我的队列中设置为 2,我希望消息传递到下一个 subscriber/flows。

但是在我的案例中,消息的发布完全是随机的。大多数情况下,第二次交付是发给同一订户(主要)。有时,第二次交付会转到备用流程。

如果有设置在订阅者之间统一分发广播。

这是期望的行为。你的subscribers/consumers没有区别。他们争夺信息。如果你想确保多个消费者可以收到你的消息,你应该使用 topics & subscriptions. If you only want to process failed messages with a different consumer, you can use the poison/dead-letter queue.

https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-queues-topics-subscriptions

If the application is unable to process the message for some reason, it can request the Service Bus service to abandon the message. Service Bus unlocks the message and makes it available to be received again, either by the same consumer or by another competing consumer.

(强调)