rebus-org / Rebus.Autofac

:bus: Autofac container adapter for Rebus
https://mookid.dk/category/rebus
Other
12 stars 11 forks source link

How to postpone bus start up? #9

Closed Maxwe11 closed 6 years ago

Maxwe11 commented 6 years ago

Hello guys, One of the common scenario for ASP .NET Core application is registering all dependencies in ConfigureServices method and applying DB migrations in Configure method in Startup class. In case of using SQL based transport for messages, database may not exist on the moment of container build up. Why Rebus.Autofac decides when to start up the bus?

mookid8000 commented 6 years ago

The Rebus/Autofac integration is made so that it initializes and starts the bus when you call containerBuilder.Build().

If you want to delay the time of when Rebus starts receiving messages, you can initialize it with zero workers

.Options(o => {
    o.SetNumberOfWorkers(0);
})

and then start receiving messages some time later by calling

bus.Advanced.Workers.SetNumberOfWorkers(2);

but I am not sure I understand what you are asking about, actually 😐 maybe you can clarify a bit, I am not really accustomed to ASP.NET Core yet....

mookid8000 commented 6 years ago

Hi @Maxwe11 , did you figure it out?

Maxwe11 commented 6 years ago

@mookid8000 I will prepare sample with repro of the problem in a couple of days.

mookid8000 commented 6 years ago


(please let me know if you still have a problem)
Maxwe11 commented 6 years ago

Not anymore, Rebus.ServiceProvider do the trick.

mookid8000 commented 6 years ago

super 😄 good to hear 👍