rebus-org / Rebus.Autofac

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

restriction to one bus per container #10

Closed martywang closed 6 years ago

martywang commented 6 years ago

Is there a reason why only one bus is allowed per autofac container? On our project we would like to register 2 buses through keyed injection, each with a different transport. Is that possible?

Thanks

mookid8000 commented 6 years ago

No, it's not possible (unless you do it manually) – and yes there is a reason 😀

Check out this question on StackOverflow and my corresponding answer.... to put it in a single sentence, it's because each bus instance is basically to be considered "an application", and one application should always be hosted in one IoC container.

You most likely want to do this because you want to create a bridge from one logical network to another (as in e.g. "receive message from MSMQ and send somewhere else via Azure Service Bus" or something like that) – that's best done by having a single Rebus instance per IoC container, and then add properly wrapped one-way clients for each outgoing transport.

I hope that makes sense 🙂 please let me know if it's not clear.