Spring

Source
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>();

Using an existing context

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

DependencyLifecycle Mapping

The NServiceBus dependency lifecycle modes do not map directly to Spring object scopes. Almost all of the lifecycle modes have been implemented using custom type registrations using a Spring GenericApplicationContext.

Samples


Last modified