Recoverability: Despite configuring otherwise, I get infinite number of immediate retries

NServiceBus version: 8.1.6.

I have the following code in my endpoint configuration:

var recoverability = endpointConfiguration.Recoverability();
recoverability.AddUnrecoverableException<InvalidSignatureException>();
recoverability.Immediate(
	immediate =>
	{
		immediate.NumberOfRetries(1);
	});
recoverability.Delayed(
	delayed =>
	{
		delayed.NumberOfRetries(2);
		delayed.TimeIncrease(TimeSpan.FromMinutes(5));
	});

But when an exception happens, “Immediate Retry” tries the message indefinitely. I looked at the Custom Recoverability Policy page, but probably misunderstood something. Do I have to configure a CustomPolicy for my configuration to take effect?

Or: do I need to configure configurability before/after some other configuration for it to work?

What’s is the transport and what is the exception?

Exception is InvalidOperationException. Something that’s thrown due to a business rule. Transport is RabbitMQ.

So an exception that is thrown from your user code? That definitely should not result in infinite retries.

Do you maybe see other exceptions after the user exception that could indicate a transport malfunction?

It seems like it may be related to this issue

So an exception that is thrown from your user code?

That’¨s right.

Do you maybe see other exceptions after the user exception that could indicate a transport malfunction?

No, I only see this exception in the logs with an immediate retry every time. And this has happened with some other business level exceptions before (in the same saga). I decided to handle those differently so that the exception doesn’t bubble up all the way to the handler.

It seems like it may be related to this issue

In the issue, the problem seems to be related to the number of messages in the queue. In my case there is generally a single message in the queue (I’m in the testing phase and there isn’t much activity other than the ones I create manually). Is there anything else that I should pay attention to?

You mentioned your NServiceBus version 8.1.6, but not the version of NServiceBus.RabbitMQ.

Have you tried updating to NServiceBus 8.2.3 and NServiceBus.RabbitMQ 8.0.5? (These are the latest versions for NServiceBus 8.)

NServiceBus.RabbitMQ version is 8.0.3. Will update the packages and test again. Thank you for the suggestion.