I use masstransit 8 + amazon sqs/sns, the app is running in Windows Docker container.
After re-read the documentation regarding exceptions handling I’ve decided to use DelayedRedelivery instead of UseMessageRetry to re-try consume messages since it doesn’t lock the consumer to wait the attempt interval but uses the capabilities of queue.
It turns out that it’s necessary to be careful with setting long time interval as it can be bad practice, at least for UseMessageRetry.
In my code I use following ConsumerDefinition:
internal class MyConsumerDefinition : ConsumerDefinition<MyConsumer>
{
protected override void ConfigureConsumer(IReceiveEndpointConfigurator endpointConfigurator, IConsumerConfigurator<MyConsumer> consumerConfigurator, IRegistrationContext context)
{
endpointConfigurator.UseKillSwitch(options =>
{
options
.SetActivationThreshold(100)
.SetTripThreshold(0.2) // 20%
.SetRestartTimeout(TimeSpan.FromMinutes(5))
.SetExceptionFilter(configurator =>
{
configurator.Handle(typeof(SocketException), typeof(EndpointNotFoundException), typeof(TimeoutException), typeof(FaultException));
});
});
endpointConfigurator.UseDelayedRedelivery(r =>
{
r.Handle(typeof(SocketException), typeof(EndpointNotFoundException), typeof(TimeoutException), typeof(FaultException));
r.Interval(3, TimeSpan.FromMinutes(15));
});
}
}
Then add it to consumer:
bus.AddConsumer<MyConsumer>(typeof(MyConsumerDefinition));
bus.AddConsumer<OtherConsumer2>();
bus.AddConsumer<OtherConsumer3>();
So I’ve got few questions just to be sure if I understand it correctly:
- What is the recommended/max good interval for RestartTimeout options in UseKillSwitch ?
- For UseDelayedRedelivery method it is OK to set interval of 15 minutes or it’s too long ?
- If I apply ConsumerDefinition for MyConsumer only, then these settings be applied automatically for other consumers (OtherConsumer2, OtherConsumer3) ?
Any recommendations will be greatly appreciated, thanks.