Wednesday, April 27, 2011

More Reasons Working with NServiceBus is Just Easier than WCF over MSMQ

We have some teams that went down the route of using WCF over MSMQ. Using a durable transport was the right thing to do for their process(accepting orders). We ran into a few issues along the way and had we used NSB to start with, we would have just avoided them.

IIS/WAS Hosting

We *thought* this would be a no brainer, but it really wasn't. Come to find out, if something goes wrong or your app pool recycles(every 24 hours or so guaranteed), you need to "warm-up" the service before it accepts messages. So Microsoft's answer to this is a warm-up extension to IIS or to host the service as a Windows Service. I think hosting in a Windows Service is a much better idea anyway as we weren't really using any of the IIS features anyway on the MSMQ transport. The thing is, had we used NSB out of the box we'd never have encountered such an issue.

Windows Service Hosting

Hosting this way gets you out of the warm-up jam. Unfortunately there is another problem if your shop uses SCOM like we do for monitoring. We haven't been able to get SCOM to monitor on the poison sub queues that WCF creates to put bad messages. We have some choices, which are call on MS to get this to work, build our own monitor, or just switch to NSB. I prefer the latter as we already have plenty of endpoints that we monitor just fine.

Summary

If you are thinking of using WCF over MSMQ make sure you host in a windows service and have a plan for when bad things happen. To us it makes sense to just retrofit those endpoints to NSB and avoid all the issues completely.

4 comments:

  1. Hi Adam,

    Did you have to warm-up the apppool even if you had MSMQ activation service running?

    Thanks,
    -Buddhike

    ReplyDelete
  2. Buddhike - yes even with WAS running. WAS just tells WCF there is a message to be processed, but if the app pool hasn't been hit yet, it won't wake it up.

    ReplyDelete
  3. What about using App Fabric and setting the startMode to always running?

    http://weblogs.asp.net/britchie/archive/2010/09/08/death-to-windows-services-long-live-appfabric.aspx

    ReplyDelete
  4. Can you think of any other reason why the WcfManager in NserviceBus could not be used to host WCFservices in an IIS process? (other than it being an internal class and expecting an exe config that is :))

    ReplyDelete