I just wanted to clear up my understanding with how MassTransit behaves in a scenario whereby a consumer throws an exception inside a subscriptionEndpoint, I believe this is the process:
我只是想澄清我对MassTransport在客户在订阅端点内抛出异常的场景中的行为的理解,我相信这是一个过程:
- Message gets delivered to topic and flows into each of its subscriptions
- MassTransit obtains a lock on the message from the broker and runs the consume method
- Consumer throws an exception
- MassTransit retries in memory if consumer definition is configured with a retry policy
- Exception is eventually thrown and a Fault is raised
- This Fault message is moved to an error queue.
- The subscription message is also moved to the Dead letter queue of that subscription
What I am mostly unclear on though is that last point . Does the message get marked as consumed and removed from the broker or does it count as faulted so we will have a message in the DLQ of the Azure Topic Subscription and in the error queue?
不过,我最不清楚的是最后一点。消息是否被标记为已使用并从代理中删除,或者它是否算作有故障,因此我们将在Azure主题订阅的DLQ和错误队列中有一条消息?
If it does end up in the dead letter does MassTransit explicitly mark it as dead lettered so Azure Service Bus does not attempt to retry delivery to the consumer(if the retry count on the subscription was 10 for example)?
如果它确实以死信结束,MassTransport是否显式地将其标记为死信,以便Azure Service Bus不会尝试重新尝试向消费者传递(例如,如果订阅的重试计数为10)?
Thanks in advance
提前谢谢你
更多回答
优秀答案推荐
This Fault message is moved to an error queue.
That is incorrect, subscription endpoints do not have error queues. Only the Azure Service Bus DLQ is used. And yes, once the retries have been exhausted, the message is dead-lettered to the subscription's DLQ.
这是不正确的,订阅终结点没有错误队列。仅使用Azure服务总线DLQ。是的,一旦重试耗尽,消息就会死气沉沉地发送到订阅的DLQ。
If the consumer process crashed, the message will be redelivered to MassTransit by Azure Service Bus up to the MaxDeliveryCount (default 10). Once that maximum delivery count is reached (assuming the process crashes every time), ASB will move the message to the subscription's DLQ.
如果消费者进程崩溃,消息将通过Azure服务总线重新传递到MassTransport,最高可达MaxDeliveryCount(默认为10)。一旦达到最大传递计数(假设进程每次都崩溃),ASB会将消息移动到订阅的DLQ。
When MassTransit moves the message to the DLQ, it adds headers describing the exception that occurred, the process, etc. ASB doesn't add anything.
当MassTransport将消息移动到DLQ时,它会添加描述发生的异常、流程等的标头。ASB不会添加任何内容。
MassTransit will only acknowledge a message once it has been successfully consumed without exception by a consumer, which will then allow ASB to remove it from the queue.
只有在消息被消费者无一例外地成功消费后,MassTransport才会确认该消息,这将允许ASB将其从队列中删除。
One additional clarification, which you didn't ask about, is message redelivery does not work with subscriptions since they are not addressable. If Azure ever adds a delayed redelivery feature (basically changing the visibility of the message to delay delivery), then MassTransit will support it as soon as it is available in the SDK.
更多回答
Thank you for the clarification and the detailed answer!
感谢您的澄清和详细的回答!
我是一名优秀的程序员,十分优秀!