Friday, November 6, 2009

Code: Windows Server 2008 R2 and Microsoft Message Queuing (MSMQ)

We’re nearing the end of a large development project in which we used MSMQ extensively.  All of our queues are private and transactional.  For the most part MSMQ works great and serves its purpose excellently.  Save one glaring issue: We have had serious issues trying to send messages to the queues from remote machines.  All of the machines are in the same domain (and location).  We’ve had the environment set up on 3 different machines (for various reasons).  The first two installs we seemed to be able to post to the queues, although it took many tries changing security permissions on the queues and changing connection string formats (TCP vs OS).  On this 3rd environment we have been totally unable to send messages to the queues from a remote machine.  The messages get eternally stuck on the sending machines outgoing queue.  In the end we believe it to be an issue with the security lockdown of Server 2008 R2.

To get around the issue we had to install MSMQ HTTP Support and send the messages over HTTP.  To do this IIS must be already installed.  Then go into Features and enable Message Queuing > Message Queing Services > HTTP Support.  This will install a MSMQ Virtual Directory/Application on the default web site.  After that we just needed to change the connection strings to below and now things work great.

Code Snippet
  1. FormatName:DIRECT=HTTP://192.168.230.86/MSMQ/Private$/transcodejobqueue