Hello,
We are currently using Castle Windsor along with the corresponding NServiceBus.CastleWindsor adapter package. I have a couple of questions as shown below:
-
Do i need to “create a scope” or “child container” for each message somewhere in the nservicebus pipeline in order to ensure that all the handlers injected dependencies get released or does nservicebus do this automatically for me?
-
If i register classes directly with castle windsor ( as scoped ) and then pass the container to nservicebus will these behave the same as if i used the nservicebus container provided interface? For example will both of the registrations below behave the same from a lifetime/lifecycle perspective?
var container = new WindsorContainer();
var registration = Component.For<MyUnitOfWork>()
.ImplementedBy<MyUnitOfWork>()
.LifestyleScoped();
container.Register(registration);
endpointConfiguration.UseContainer<WindsorBuilder>(
customizations: customizations =>
{
customizations.ExistingContainer(container);
});
endpointConfiguration.RegisterComponents(
registration: components =>
{
components.ConfigureComponent<MyUnitOfWork>(DependencyLifecycle.InstancePerUnitOfWork);
});