MT3 with SM3 configuration

85 views
Skip to first unread message

Cobus Bernard

unread,
Oct 13, 2015, 8:14:32 AM10/13/15
to masstransit-discuss
Would it be possible to get an updated configuration sample for RabbitMQ? When using StructureMap 3.1.6.191 with MT 3.0.14, I am not able to configure it for RabbitMQ,: A lambda expression with a statement body cannot be converted to an expression tree

I have gotten it mostly working:

public BusRegistry()

{

    For<IBusControl>(new SingletonLifecycle())

        .Use(x => Bus.Factory.CreateUsingRabbitMq(ConfigureRabbit));


    Forward<IBus, IBusControl>();

}


private void ConfigureRabbit(IRabbitMqBusFactoryConfigurator cfg)

{

    Log4NetLogger.Use();

    var hostAddress = new Uri("rabbitmq://10.0.0.1/");

    var host = cfg.Host(hostAddress, ConfigureHost);

    cfg.ReceiveEndpoint(host, "MainBus", ConfigureEndpoint);

}


private void ConfigureEndpoint(IRabbitMqReceiveEndpointConfigurator cfg)

{

    //Register Handlers here

}

        

private static void ConfigureHost(IRabbitMqHostConfigurator cfg)

{

    cfg.Username("username");

    cfg.Password("password");

}



I understand the issue: I am trying to call the container to resolve a dependency during startup, but not sure how else to go about registering the Handlers other than the constructor way. With SM2, it was possible to use the samples from the docs, i.e.:


var hostAddress = new Uri("rabbitmq://10.0.0.1/");

For<IBusControl>(new SingletonLifecycle())

    .Use(x => MassTransit.Bus.Factory.CreateUsingRabbitMq(sbs =>

    {

        var host = sbs.Host(hostAddress, h =>

        {

            h.Username("username");

            h.Password("password");

        });


        sbs.ReceiveEndpoint(host, "MainBus", ep =>

        {

            ep.Consumer(() => new MessageHandler(

                x.GetInstance<ISomeService>()));

        });

    })

);


It feels like I am missing something significant here, but can't think that I would be unable to inject a service into the handler.

Phil Croft

unread,
Nov 16, 2015, 3:40:23 PM11/16/15
to masstransit-discuss
Did anyone ever make progress on this?
Reply all
Reply to author
Forward
0 new messages