Search code examples
c#asp.netmsmqiis-expressmasstransit

Can't get MassTransit with MSMQ to work on IIS Express


I have a .NET MVC 4 web app that uses MassTransit with MSMQ. We have several legacy apps that use MSMQ, so I'm constrained to that protocol. My client code in Application_Start() in my global.asax.cs file looks like this:

Bus.Initialize(sbc =>
{
    sbc.UseMsmq(a => a.UseSubscriptionService("msmq://localhost/mt_subscriptions"));
    sbc.ReceiveFrom("msmq://localhost/webconsole?tx=false&recoverable=false");
    sbc.UseControlBus();
    sbc.UseBinarySerializer();
});

I'm running this app on a Windows 8.1 developer box, and this call completes successfully & communications work as expected when I run it on IIS 8.5. However, when I run it on IIS Express 8.0, the call never completes and will eventually throw a timeout error. I found the following in the IIS Express FAQ:

    Q: Does IIS Express support non-HTTP protocols such as net.tcp or MSMQ?

    A: No. IIS Express only supports HTTP and HTTPS as its protocol.

Ok, fair enough, but I don't understand what the web server has to do with MSMQ (aside from using MSMQ over HTTP, which I am not attempting to do); I don't have any "msmq://" routes or anything like that. Doesn't MassTransit use MSMQ directly without going through the web server? And I can't believe that I'm the only developer out there who develops on IIS Express with MassTransit.

Any insights as to what is going on here? Thanks!


Solution

  • So I did finally figure this out, I thought I would post the answer to perhaps save someone else from banging their head against this particular wall. During startup, MassTransit looks to see if Windows Performance Counters are available. For some reason, checking for their existence when running on IIS Express results in a hung call. You can find an entire discussion thread on the subject here, it's also been an issue for SignalR and Windsor Castle developers: https://groups.google.com/forum/#!topic/masstransit-discuss/Pz7ttS7niGQ. As a result of the discussion, the MassTransit developers added a DisablePerformanceCounters() method to their API, and calling that method when creating the service bus fixed my problem.