We would like to raise critical errors in our service. It is important that we enabled an ‘Outbox’ feature in our service.
So I added such a code inside a message handler:
// Some logic (e.g store entity to the database)
if (condition)
{
criticalError.Raise("Test critical error", new ArgumentException("Test error"));
}
// Send messages through nservicebus to another service
I expected that if my condition is true, then the critical error will occur and the transaction will be rolled back, no messages will be sent to another service.
And according to the documentation the default behavior for critical errors is to log the exception and keep retrying indefinitely: https://docs.particular.net/nservicebus/hosting/critical-errors
However, in my case, the handler was successfully completed: entity stored to the database, message sent to another service.
The only thing that I can see is an error in logs, but no retries happened: