Provides an Autofac container adapter for Rebus
Get Started
| Product | Versions |
|---|---|
| .NET Standard |
README
Rebus.Autofac
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 singletonIBusStarterβ this is the bus starter you can use to start it manuallyIMessageContextβ this is the current message context β can be injected into Rebus message handlers and everything resolved at the time of receiving a new messageISyncBusβ this is the synchronous bus instance β can be used in places, where aTask-based asynchronous API is not desired, e.g. from deep within ASP.NET or WPF applications, which would deadlock if you went.Wait()on aTask
Not that if you wish to regiser the bus and not start it automatically, you can stil register the number of workers but have it not start anything until you are ready for the bus to be started. This is usefu if you wish to separate the processing of messages from the sending of messages (separate tasks, services etc). You would do it 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);
}),
false); // <--- here we tell it not to start the bus
// the bus is registered now, but it has not been started.... make all your other registrations, and then:
var container = builder.Build();
var busStarter = container.Resolve<IBusStarter>();
busStarter.Start(); //< start the bus
// now your application is running
// ALWAYS do this when your application shuts down:
container.Dispose();
Downloads by Version
Similar & Alternative Packages
Hand-picked matching NuGet libraries based on tags & ecosystem
Depended On By
Find packages that declare this package as a dependency. NuGet does not provide a reverse-dependency endpoint, so candidates are checked on demand.
Adoption Assessment
Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.