Skip to content

Latest commit

 

History

History
41 lines (25 loc) · 1.44 KB

README.md

File metadata and controls

41 lines (25 loc) · 1.44 KB

Rebus.Autofac

install from nuget

Provides an Autofac container adapter for Rebus.


Use the Autofac container adapter like this:

var builder = new ContainerBuilder();

builder.RegisterRebus((configurer, context) => configurer
    .Logging(l => l.Serilog())
    .Transport(t => t.UseRabbitMq(...))
    .Options(o => {
        o.SetNumberOfWorkers(2);
        o.SetMaxParallelism(30);
    }));

// the bus is registered now, but it has not been started.... make all your other registrations, and then:
var container = builder.Build(); //< start the bus



// now your application is running



// ALWAYS do this when your application shuts down:
container.Dispose();

It will automatically register the following services in Autofac:

  • IBus – this is the bus singleton
  • IMessageContext – this is the current message context – can be injected into Rebus message handlers and everything resolved at the time of receiving a new message
  • ISyncBus – this is the synchronous bus instance – can be used in places, where a Task-based asynchronous API is not desired, e.g. from deep within ASP.NET or WPF applications, which would deadlock if you went .Wait() on a Task