MSMQ over HTTP and Load Balancer - Part 1

MSMQ 3.0 introduced many new features like Internet Messaging (referencing queues via HTTP, SOAP-formatted messages, MSMQ support for Internet Information Services), queue aliases, multi casting of messages, and additional support for programmatic maintenance and administration of queues and MSMQ itself (source Wikipedia).

I have seen many posts on MSMQ and most of them explained working with local queues. So I decided to write about communicating with Remote queues over HTTP and the problems I faced during implementation. To keep it simple I decided to break this post in parts. First we will see how to setup MSMQ to work over HTTP. Next part we will talk about sending messages and confirming their delivery. Finally we will see what additional steps are required if the architecture involves load balanced environment. So this post does not focus on what MSMQ is, what it does, types of queues, different ways to connect to queues etc because that would take series of articles.

Before Proceeding

When you enable HTTP support, a virtual directory 'MSMQ' is created in IIS. MSMQ is designed in such a way that virtual directory will always be created under Default Web Site in IIS. So if you don't have default one (yes quite possible), create it and make sure site id is set to 1. If it is not 1, then MSMQ will create virtual directory under whichever site has id 1 even though you created default web site. Site ID is important!

Enable HTTP support

By default HTTP support is not enabled. To do so, go to Server manager > features > Add Features > Message Queuing > Message Queuing Services > HTTP Support. Check the box and click Next. You may be required to install dependent features and/or roles for this, however, this will be taken care by Windows. Just keep proceeding.

Verify HTTP support

Once enabled, quick way to verify is by browsing to http://localhost/msmq (virtual directory name is not case-sensitive). I used 8080 port because there is another site running on 80 and 443 ports.

Looks like something went wrong!? No it did not. In fact, this is what we need. It shows that we connected to MSMQ successfully, however, it was not a valid message that MSMQ could understand. First image is when you hit the MSMQ locally and 2nd when you do so remotely.

Now that we are done with the initial configuration and before we start sending messages, remember these things:
  1. Private queues cannot be created remotely (through code). They need to be created manually on the server.
  2. You cannot check for the existence of remote queues. Next part we will talk about this.
  3. Messages cannot be received over HTTP protocol. They can only be sent.
In the next part, we will see how to communicate with the remote queue and what are the ways to confirm message delivery.

No comments:

Post a Comment