Domanda

I'm using NServiceBus 4.0.3 with the Ninject builder and cannot figure out how to register message mutators (IMutateTransportMessages).

I've registered the mutator with the Ninject Kernel but it is never invoked. Below is how I'm configuring NServiceBus:

private static IBus ConfigureBus(IKernel kernel)
{
    kernel.Bind<IMutateTransportMessages>().To<SendTenantIdMutator>();

    return NServiceBus.Configure.With()
        .NinjectBuilder(kernel)
        .XmlSerializer()
        .MsmqTransport()
            .IsTransactional(false)
            .PurgeOnStartup(true)
        .UnicastBus()
            .LoadMessageHandlers()
        .CreateBus()
        .Start(() => Configure.Instance.ForInstallationOn<Windows>().Install());
}
È stato utile?

Soluzione

Is there some special reason to register the mutator directly with Ninject as opposed to the regular NServiceBus container API:

Configure.Component<SendTenantIdMutator>(Dependency‌​Lifecycle.SingleInstance);

I mean, this just calls internally into the configured container, which in your case would be Ninject.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top