MSMQ: no se puede recibir de las colas de multidifusión

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.

Aquí es donde estoy:

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 esta pregunta but that has no affect.

preguntado el 03 de mayo de 12 a las 17:05

2 Respuestas

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.

respondido 07 nov., 16:13

Hi Peter, I followed these steps still i am unable to receive message in different machine, it's working fine in same machine, I saw that message in event log, it was suggesting 2 IP in message, I added key with that IP. - Rajesh Mishra

The technet link is dead. Could you update or remove it? - Sean B.

@SeanB replaced the link with another which hopefully conveys the right information, it was quite a while ago! - pedro monjes

I solved same my problem by other way:

  1. Create private queue with multicast address.
  2. Create queue in producer by next

    const string QUEUE_PATH = @"formatname:MULTICAST=234.1.1.1:8001"

    MessageQueue mq = new MessageQueue(QUEUE_PATH)

  3. Create consumer queue next (each consumer has different name!):

consumer1:

const string QUEUE_PATH = @".\Private$\MSMQ-Task3-Consumer-1";

MessageQueue mq = !MessageQueue.Exists(QUEUE_PATH) ? MessageQueue.Create(QUEUE_PATH) : new MessageQueue(QUEUE_PATH);

mq.MulticastAddress = "234.1.1.1:8001";

consumer2:

const string QUEUE_PATH = @".\Private$\MSMQ-Task3-Consumer-2";

MessageQueue mq = !MessageQueue.Exists(QUEUE_PATH) ? MessageQueue.Create(QUEUE_PATH) : new MessageQueue(QUEUE_PATH);

mq.MulticastAddress = "234.1.1.1:8001";

Sources can be found here: https://github.com/constructor-igor/TechSugar/tree/master/MessageQueue

Short Settings explanation can be found: https://github.com/constructor-igor/TechSugar/wiki/MessageQueue

respondido 01 nov., 16:16

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.