Skip to content

Instantly share code, notes, and snippets.

@sjdweb
Created June 16, 2015 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sjdweb/4ae29fc71383a4954f2f to your computer and use it in GitHub Desktop.
Save sjdweb/4ae29fc71383a4954f2f to your computer and use it in GitHub Desktop.
MassTransit StructureMap Extensions
namespace MyApp.MassTransitExtensions
{
using MassTransit;
using StructureMap;
using StructureMap.Graph;
public static class MassTransitStructureMapExtensions
{
public static void ScanConsumers(this IContainer container)
{
container.Configure(
x =>
{
x.Scan(
s =>
{
s.TheCallingAssembly();
s.AddAllTypesOf<IConsumer>();
});
});
}
public static void InjectBus(this IContainer container)
{
var bus = ServiceBusFactory.New(
sbc =>
{
sbc.UseRabbitMq();
sbc.ReceiveFrom("rabbitmq://localhost/myqueue");
sbc.UseJsonSerializer();
sbc.Subscribe(s => s.LoadFrom(container));
});
container.Configure(
c =>
{
c.For<IServiceBus>().Singleton().Use(x => bus);
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment