I'm using MassTransit (5.5.5) with StructureMap (4.7) in a large code base, using Registry classes to keep my dependencies organized, following what's outlined here:
class BusRegistry : Registry
{
public BusRegistry()
{
For<IBusControl>(new SingletonLifecycle())
.Use(context => Bus.Factory.CreateUsingInMemory(x =>
{
x.ReceiveEndpoint("customer_update_queue", e => e.LoadFrom(context));
}));
Forward<IBusControl, IBus>();
}
}
// Snip...
public void CreateContainer()
{
_container = new Container(x => {
x.AddRegistry(new BusRegistry());
});
}
However, the LoadFrom extension method used in the call to ReceiveEndpoint is deprecated. So how is one supposed to use MassTransit with StructureMap Registry classes currently?
There probably isn't going to be a good answer, since StructureMap is on its way out. I ended up not using StructureMap for consumer configuration:
class BusRegistry : Registry
{
public BusRegistry()
{
For<IBusControl>(new SingletonLifecycle())
.Use(context => Bus.Factory.CreateUsingInMemory(x =>
{
x.ReceiveEndpoint("customer_update_queue", endpointCfg => {
endpointCfg.Consumer<FirstSubscriber>(
GetFirstSubscriberFactoryMethod()
);
endpointCfg.Consumer<SecondSubscriber>(
GetSecondSubscriberFactoryMethod()
);
// etc...
});
}));
Forward<IBusControl, IBus>();
}
}
...though I am using StructureMap to inject dependencies into the consumers.