MT3 + IoC + ASP.NET/OWIN question

72 views
Skip to first unread message

mald

unread,
Jul 12, 2015, 10:43:41 AM7/12/15
to masstrans...@googlegroups.com
I'm using Autofac to wire up my bus, but the problem I'm encountering is that IBus, does not have the .Start() method. It's only IBusControl.

builder.Register(c => Bus.Factory.CreateUsingRabbitMq(sbc =>
    {
        var host = sbc.Host(new Uri("rabbitmq://localhost/myvhost"), h =>
        {
            h.Username("myvhost");
            h.Password("password");
        });
                  sbc.ReceiveEndpoint(host, "my_queue", e => e.Consumer<MyConsumer>());
    }))
    .As<IBus>()
    .SingleInstance();

Should I be ditching IBus, in favor of IBusControl? Or make it available as all implemented interfaces? Also what would be the best place to call .Start() and save the handle? I'm using OWIN for asp.net, so I have a:

public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            // Calling autofac modules to wire it up
            // When done calling autofac modules, should I be calling the .start() here, and save the handle?
            // Do I care to save the handle, or let IDisposable do the work once the Application Pool is recycled?
    }
}

Thanks

Chris Patterson

unread,
Jul 12, 2015, 5:39:29 PM7/12/15
to masstrans...@googlegroups.com
If you're using Autofac, you can register as multiple interfaces, so you can use

.As<IBus>()
.As<IBusControl>()
.SingleInstance();

Caching the handle should be doable as well, using a factory method that uses IBusControl() and calls Start(). There is a startable feature in Autofac, but I find it makes the error messages super confusing so I do it post container building.


--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/97afcfc1-0821-4039-b5ce-2bddc7f4a79e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages