Closed CzechsMix closed 4 years ago
I think actually this is because of the new two-step semi-idiomatic way of registering and starting things in .NET Core, which usually goes like this:
First you
services.Add****
to make the necessary registrations in the IoC container, and then you
app.Use***
to activate it.
With Rebus, it goes like this:
services.AddRebus(configure => configure.Transport(...));
and
app.UseRebus();
Did this solve your issue?
Please let me know if it didn't. 🙂
I wrapped Rebus in a custom service that I registered as a IHostedService and it solved my issue if the app was set to start automatically in IIS. I no longer had to have an app.UserRebus statement.
alternatively, something like Pinging a health check in my release pipeline also worked.
I've noticed that using the method of acting on the bus in the request pipeline, the bus doesn't start until the application actually receives a request and builds the pipeline. (I suspect it is also executing this step on each request, but have not yet taken the time to confirm)
I think the correct work around is to wrap IBus in some IHostedService (in order to subscribe/unscrubribe when starting/stopping as needed). Should the documentation be amended to include instructions for this, or is it worth providing a Rebus "native" way of supporting services.AddHostedService<>() ?