I have just started to add Rebus support to a fairly large commercial system, comprising of a lot of de-coupled components that will each perform service registrations and initialization steps during the app startup.
There appear to be 2 big problems with the current NetCoreServiceCollectionContainerAdapter that have prevented me from using it:
The service provider is built every time a message is handled (on every call to IContainerAdapter.GetHandlers(...). As well as performance concerns, it also breaks any singleton lifestyle behavior required by any application services (that are injected into handlers). You also couldn't configure a handler to be a singleton if you wanted.
The IBus must be started before it is registered in the service collection, at which point, it will start to handle messages - and so potentially create handlers that could require services that are not yet registered in the service collection.
I have written a solution to this for my current project, out of necessity, and also have made it available in my fork here: https://github.com/trevorreeves/Rebus.ServiceProvider. Let me know if you are interested, and any thoughts on it, and I'll create a PR. Happy to develop it further based on any input you have, plus develop the readme. I have provided some tests, but haven't managed to successfully get Nunit running them yet... can put in more time if it's a go-er.
I have just started to add Rebus support to a fairly large commercial system, comprising of a lot of de-coupled components that will each perform service registrations and initialization steps during the app startup.
There appear to be 2 big problems with the current
NetCoreServiceCollectionContainerAdapter
that have prevented me from using it:The service provider is built every time a message is handled (on every call to
IContainerAdapter.GetHandlers(...)
. As well as performance concerns, it also breaks any singleton lifestyle behavior required by any application services (that are injected into handlers). You also couldn't configure a handler to be a singleton if you wanted.The
IBus
must be started before it is registered in the service collection, at which point, it will start to handle messages - and so potentially create handlers that could require services that are not yet registered in the service collection.I have written a solution to this for my current project, out of necessity, and also have made it available in my fork here: https://github.com/trevorreeves/Rebus.ServiceProvider. Let me know if you are interested, and any thoughts on it, and I'll create a PR. Happy to develop it further based on any input you have, plus develop the readme. I have provided some tests, but haven't managed to successfully get Nunit running them yet... can put in more time if it's a go-er.
Cheers
Trevor.