Created
November 8, 2011 13:53
-
-
Save CraigStuntz/1347782 to your computer and use it in GitHub Desktop.
Possible means of using Autofac with MassTransit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(string[] args) | |
{ | |
var builder = new ContainerBuilder(); | |
// register each consumer manually | |
builder.RegisterType<YourConsumer>().As<IConsumer>(); | |
//or use Autofac's scanning capabilities -- SomeClass is any class in the correct assembly | |
builder.RegisterAssemblyTypes(typeof(SomeClass).Assembly).As<IConsumer>(); | |
//now we add the bus | |
builder.Register(c => ServiceBusFactory.New(sbc => | |
{ | |
//other configuration options | |
//this will find all of the consumers in the container and | |
//register them with the bus. | |
sbc.LoadFrom(c); | |
})).As<IServiceBus>() | |
.SingleInstance(); | |
var container = builder.Build(); | |
} | |
// Note: We recommend that most of this code be placed in an Autofac Module | |
// ( http://code.google.com/p/autofac/wiki/StructuringWithModules ) |
Ok, that's what I want. Thanks. Its now in the docs. :)
Yeah, but that's less explicit for most users. Keep it concrete, keep it clear. ;)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One could also use
Assembly.GetExecutingAssembly
.