Should I override critical error handling or not?

I found conflicting information in this doc: Critical Errors • NServiceBus • Particular Docs

Under “Default Behavior” section is says
“The default behavior is to log the exception and keep retrying indefinitely.”

Then under “When to override the default critical error action” section, it also says
“The default action should always be overridden when self-hosting NServiceBus, as by default when a critical error occurs the endpoint will stop without exiting the process.”

My goal is that I don’t want my endpoints (hosted in web apps) be stopped by critical errors. Because my transport may eventually back online and I want my endpoints to continue to send messages without having to restart them.

I did a quick test - shutting down RabbitMQ then turning it back on. Without overriding the critical errors, my endpoints were able to send message again - I saw the circuit breaker “is not disarmed” in the log. So I don’t have to override it then?

Thanks!

Hi Calvin,

Overriding critical error should be used when you need to take a drastic action. For example, you want to kill the hosting process used to host the endpoint to allow the system to restart the host. Otherwise, in scenario like yours, you don’t need to override it.

Thank you Sean for the confirmation.

Critical error callback always needs to be overridden when self-hosting on NServiceBus versions prior to version 7. The documentation you are linking and quoting is version 7. If you are indeed using version 7 then you do not have to do anything but if you are using an older version you should add a critical error callback.

Thanks for mentioning the inconsistency with the “When to override the default critical error action” action as that needs to be updated with the behavior for version 7.

– Ramon