# Ninject

The following example shows how to configure a simple Ninject container, and include the bus in the container. The two bus interfaces, IBus and IBusControl, are included.


Consumers should not typically depend upon IBus or IBusControl. A consumer should use the ConsumeContext instead, which has all of the same methods as IBus, but is scoped to the receive endpoint. This ensures that messages can be tracked between consumers, and are sent from the proper address.

public static void main(string[] args) 
    var kernel = new StandardKernel();

    // register a specific consumer
    // just register all the consumers using Ninject.Extensions.Conventions
    kernel.Bind(x =>
    var busControl = Bus.Factory.CreateUsingRabbitMq(cfg =>
        var host = cfg.Host(new Uri("rabbitmq://localhost/"), h =>

        sbc.ReceiveEndpoint("customer_update_queue", ec =>
        .ToProvider(new CallbackProvider<IBus>(x => x.Kernel.Get<IBusControl>()));


The behavior with Ninject is slightly different, in that the current AppDomain types are checked against the container and if any consumer types are registered, they are resolved from the container. The unit tests pass, and it works, but just be aware that container metadata is not being used to support this feature. There is some history on this, found at the Ninject issue.