Spring

Project Hosting
NuGet Package NServiceBus.Spring (6.x)
Target NServiceBus Version: 5.x

NServiceBus can be configured to use Spring for dependency injection.

Default Usage

busConfiguration.UseContainer<SpringBuilder>();

Existing Instance

var applicationContext = new GenericApplicationContext();
applicationContext.ObjectFactory
    .RegisterSingleton("MyService", new MyService());
busConfiguration.UseContainer<SpringBuilder>(
    customizations: customizations =>
    {
        customizations.ExistingApplicationContext(applicationContext);
    });

DependencyLifecycle Mapping

The way that the NServiceBus.Spring adapter is implemented means that the dependency lifecycle's of NServiceBus do not map directly to Spring Object Scopes. Almost all of the lifecycles have been implemented using a custom type regsitrations on top of a Generic Application Context.

Samples


Last modified