Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSMQ - Cannot receive from Multicast queues

Tags:

c#

msmq

multicast

I am trying to get my head around how multicasting works in MSMQ but I cannot receive messages at all, even from the same machine. I'm obviously doing something wrong but cannot see what.

Here's where I'm at:

I manually created a non-transactional private queue called MulticastTest and then set the Multicast address to 234.1.1.1:8001. Then my test sending app does this:

MessageQueue queue = new MessageQueue("FormatName:MULTICAST=234.1.1.1:8001");
queue.Send("Hello World");

This works, it at least seems to send the message which I see in an outgoing queue on the same machine. At least I assume this is correct, please tell me if it isn't.

So now I try and run my receiving app (either on the same machine or a different one configured to the same multicast address) and I cannot get it to work. If I try this:

MessageQueue queue = new MessageQueue("FormatName:MULTICAST=234.1.1.1:8001");
var message = queue.Receive();

It simply won't work, the Receive() method throws an exception saying:

The specified format name does not support the requested operation. For example, a direct queue format name cannot be deleted

If I try and set the receiving queue as .\private$\MulticastTest it at least waits for a message but nothing happens, all messages still stay in the outgoing queue.

So what am I doing wrong? Does some kind of service need to be running for MSMQ to send out messages from the outgoing queue?

I have also tried giving full permissions to the ANONYMOUS USER as per this question but that has no affect.

like image 490
Peter Monks Avatar asked May 03 '12 16:05

Peter Monks


1 Answers

After much experimentation I finally figured out the correct steps I needed to get multicast queues to work.

First and foremost, make sure you've got the MSMQ Multicast feature installed! Despite being able to create a queue with a multicast address on one of my servers, Server Manager actually told me that the component wasn't installed.

After trying this out on my local machine instead I found this message in my event log:

Message Queuing found multiple IP addresses for the local computer. Message Queuing will use the default IP address determined by the PGM driver for multicast messages. To use a different IP address, set the \HKLM\Software\Microsoft\MSMQ\Parameters\MulticastBindIP registry value to one of the following valid IP addresses: [IP addresses listed here]

It turns out I had multiple IP address for my local area network, so first I added this registry key using the correct IP address needed to send out messages and then restart the Message Queueing service. More details can be found here: https://technet.microsoft.com/en-us/library/cc770813%28v=ws.10%29.aspx?f=255&MSPPError=-2147217396

Next I had to add permissions to my message queue for the ANONYMOUS LOGON user, so I gave (at a minimum) Receive and Send permissions.

Now to send something. The correct format of the queue name you need is as follows:

FormatName:MULTICAST=234.1.1.1:8001

or whatever your multicast IP address/port is. My sending app now sent out the message and I could see that it now appears in my private queue which is tied to this multicast address. This means that the message has definitely been sent.

On the receiving end, I need to listen to the private queue (not the multicast format above), so I listen on:

.\private$\MulticastTest

Finally I see the message I sent appear on the receiving end.

As a sanity check I setup another queue pointing to the same multicast address (making sure on that machine I followed the same steps above) and can now send a message from one machine and have it received by multiple machines.

I hope this answer is of help to others as it was a real trial-and-error effort for me.

like image 170
Peter Monks Avatar answered Oct 07 '22 23:10

Peter Monks