You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Registering bus.Dispose() in IHostApplicationLifetime.ApplicationStopping causes the bus to be disposed before the generic host stops the hosted services
code from RebusInitializer:
// stopping the bus here will ensure that we've finished executing all message handlers when the container is disposed
stoppingToken.Register(() =>
{
logger?.LogDebug("Stopping token signaled - disposing bus instance {busInstance}", bus);
bus.Dispose();
logger?.LogInformation("Bus instance {busInstance} successfully disposed", bus);
});
When I commented out the registration mentioned above, everything worked fine, including the order of stopping RebusBackgroundService.
The text was updated successfully, but these errors were encountered:
Hmm actually this might call for giving Rebus the ability to wait for currently executing message handlers to finish - this way, the stopping token above could just set the number of workers to 0 (thus preventing that additional messages are fetched), and then block, waiting for currently executing message handlers to finish.
This bus could then be disposed at a later point in time when everything else has shut down.
I'll run a couple of experiments to see if that would be feasible.
Registering bus.Dispose() in IHostApplicationLifetime.ApplicationStopping causes the bus to be disposed before the generic host stops the hosted services
code from RebusInitializer:
When I commented out the registration mentioned above, everything worked fine, including the order of stopping RebusBackgroundService.
The text was updated successfully, but these errors were encountered: