Closed tpetrina closed 4 years ago
Yes, but you need to handle that yourself. 😐
The reason Rebus lets errors bubble out during startup, is so you don't accidentally start it up with the wrong connection string and never find out. By letting errors bubble out at this point in time, it's up to the caller (usually the startup procedure of a web application or a background service) to figure out what to do.
Many times, you simply want to let the process crash, and then let whichever hosting environment you're using report the error and possibly try to restart it.
I can definitely understand why it would be easier for you if Rebus handled that by itself, but it would push a lot of complexity down into Rebus, because it would not be able to run through its normal lifecycle (initialize/run/dispose), if the initialization had failed.
Ok, fair enough. Does Rebus expose enough APIs for us to manage connection retries or check if the connection was successful?
Not readily, no. But you should be able to wrap the initialization with try-catch
try
{
Configure.With(...)
.(...)
.Start();
}
catch (Exception exception)
{
// maybe log it and wait a while
}
and then keep trying until it succeeds.
Is it possible to prevent crash on app startup when the connection to RabbitMQ is not available? Rebus is not an essential part of the service and I would prefer using health checks to indicate the status of missing/unavailable connections rather than crashing on startup.
The applications are built on .NET Core either as a Windows Service or ASP.NET Core apps.