Reputation: 248
I am trying to use MassTransit in a very reliable message based system based around Azure Service Bus. When message processing errors occurs MassTransit moves the message to an error/fault queue. I know I can do retries with policies on the consumer, and I am. What I want to configure is for MassTransit to try to process the message, if an error happens, Abandon the message so it's returned back to the front of the subscription for another subscriber to pick up.
I'm trying to use this in combination with a custom circuit breaker that breaks immediately when a processing error happens.
This will increment the Delivery Count on Service Bus and eventually might lead to dead lettering, but we already have non-masstransit based approaches to handle that.
So is there a way to disable all the Error queue functionality and just Abandon the message?
Upvotes: 1
Views: 2305
Reputation: 41090
If you are configuring MassTransit with dependency injection like so:
services.AddMassTransit(x =>
{
x.UsingRabbitMq((context, cfg) => // Instead of RabbitMQ, could be UsingAzureServiceBus or UsingAmazonSQS
{
cfg.ConfigureEndpoints(context);
});
});
Then the way to disable a dead letter queue is to use a Consumer Definition like so:
public class SubmitOrderConsumerDefinition :
ConsumerDefinition<SubmitOrderConsumer>
{
protected override void ConfigureConsumer(IReceiveEndpointConfigurator endpointConfigurator, IConsumerConfigurator<SubmitOrderConsumer> consumerConfigurator, IRegistrationContext context)
{
endpointConfigurator.DiscardFaultedMessages();
endpointConfigurator.DiscardSkippedMessages();
}
}
Upvotes: 0
Reputation: 33268
You can configure the receive endpoint with:
cfg.ThrowOnSkippedMessages();
cfg.RethrowFaultedMessages();
That will propagate the error back up to service bus (either the subscription or the queue) and let the MaxDeliveryCount ultimately decide if it ends up in the DLQ.
Upvotes: 3