Queued WCF Services, MSMQ, IIS7 and NetMsmqActivator. Oh My.

First of all; credits for this solution goes to a former colleague, and now a contractor working in my department; Erlend Rotvik of WebStep Fokus.

The title might be a bit cryptic, so let me elaborate a bit on the subject; until last week or so, it was “common knowledge” that using the NetMsmqActivator together with Queued WCF services hosted in different IIS7 sites was a no-go. The reason for this “truth” was that there wasn’t a way to specify how the NetMsmqActivator should dispatch messages to the different IIS sites.

If you experience exceptions like this one:


or get this one in your face unexpectedly:

you’ve probably being screwed by the NetMsmqActivator with wrong binding information set.

When you set up an net.msmq on your IIS7 site, the binding information you enter is normally localhost, so Erlend played a bit with the syntax and found out that if he used an asterisk (*) he could filter on specific queues. Since we prefix all MSMQ queues based on the project / services they belong to, he tried to put the prefix before the asterisk – and lo and behold; now the NetMsmqActivator only dispatched messages from the queues that matched the prefix! As far as I know, this isn’t documented, so head over to a local IIS7 installation of yours and try it out!

Example binding information:


would tell the NetMsmqDispatcher to only dispatch messages in queues named MySite.* to the given IIS Web Site.


Be Sociable, Share!

  • http://twitter.com/paulmsuart Paul Suart

    Hi Lars.  Thanks for posting this – you’ve just made my day!  Solved my problem perfectly :)

  • Teddy G.

    Lars,  this is one of handful of sites that talk about this issue.   I’m surprised it wasn’t corrected in a fix pack years ago.   I guess not many people need to mix WCF/non-WCF queues on the same machine.

    Sadly, your tip only got me half way there.  After adding the virtual directory path to the localhost binding, WAS would no longer crash but MSMQ Auto-activation would no longer work. 

    The fix for me was to install AppFabric for Windows Server v1.1.  (Must have for anyone using WAS/IIS hosted WCF services or WF applications.)   I was also able to remove the “localhost/virtual_path*” binding.