Configuring Unity

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

Note: 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 container = new UnityContainer(); 

    // register each consumer
    container.RegisterType<UpdateCustomerAddressConsumer>(new ContainerControlledLifetimeManager());

    // scan for types
    var consumerTypes = new TypeFinder().FindTypesWhichImplement(typeof(IConsumer));
    foreach (var consumerType in consumerTypes)
        container.RegisterType(consumerType, new ContainerControlledLifetimeManager());

    var busControl = Bus.Factory.CreateUsingRabbitMq(cfg =>
        var host = cfg.Host(new Uri("rabbitmq://localhost/"), h =>

        sbc.ReceiveEndpoint("customer_update_queue", ec =>



results matching ""

    No results matching ""