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());
}
有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top