Paul Harding
Paul Harding

Reputation: 43

NServiceBus & Bootstrapper StructureMap

I am using NServiceBus is an azure worker role via convention by having configuration in app.config and azure Queue details in .csdef.

I have a rest service that accesses the IBus by doing this:

Configure.Instance.Builder.Build<IBus>()

and works fine!

I have a class that implements IWantToRunAtStartup where I do the configure bootstrapper as follows:

    Bootstrapper.With.StructureMap()
        .UsingAutoRegistration()
        .And.AutoMapper().Start();

I'm losing the IBus reference if I then use the bootstrap container:

Configure.Instance.StructureMapBuilder((IContainer) Bootstrapper.Container);

How do I use Bootsrtrapper.StructureMap and NServiceBus?

Upvotes: 0

Views: 350

Answers (1)

John Simons
John Simons

Reputation: 4288

Telling us which container you want to use needs to be done from a IConfigureThisEndpoint and IWantCustomInitialization class, example:

public class EndpointConfig : IConfigureThisEndpoint, AsA_Server, IWantCustomInitialization
{
    public void Init()
    {
        Configure.With()
            .StructureMapBuilder((IContainer) Bootstrapper.Container);
    }
}

Upvotes: 1

Related Questions