.Net Core Web Application Stops Processing the messages after Critical Errors

Hello Team,

We are using:
• NServiceBus 7.7.3
• NServiceBus.SqlServer 6.3.1

We have hosted the web API on IIS and use the NService Bus within this web API. We have used SQL Server as a transport for our NService Bus.

We took our SQL Server instance that we use for NServiceBus down for patching updates (planned), and post that SQL peeks operation started failing and the endpoint did not resume processing incoming messages as a result.

Two minutes after the web API application went down, I noted the following in the log: “The circuit breaker for SqlPeek is now in the armed state.”

I wanted a way to restart the host process so that it automatically starts the endpoint once the transport is available and it does not stop the web API application.

This is an application log screenshot of when the issues started to occur and after 2 minutes the host process terminates.

Hi Team,

Any updates on this issue?

Quoting from this other thread:

Once the critical error happens, you have to assume that the endpoint is dead. A normal critical error action on a backend endpoint SHOULD call Environment.FailFast() or similar to halt the process so that operations people can notice it’s dead and come to the rescue. The only reason an endpoint doesn’t do that by default is that it could be hosted in a webapp and it would be a poor experience to crash your website against your wishes because the transport is down.

If I understand your case correctly, you probably want to stop the web application: Critical Errors • NServiceBus • Particular Docs. IIS will take care of starting a new one.

Hi mauroservienti,

Thank you for your response.

When the application is unable to access the SQL transport, the Web API is terminated in my case.
You can see in the screenshot above that once the critical error is encountered, the Web API application shuts down on its own.

I needed a way to restart the Web API host process so that when the transport becomes available, it automatically starts the NService Bus endpoint and does not stop the web API application.

IIS should automatically do that for you. When the hosted web API crashes the application pool is recycled and at the next request should be automatically restarted by IIS.

Isn’t that happening?