MSMQ - Cannot receive from Multicast queues

后端 未结 2 378
醉酒成梦
醉酒成梦 2021-01-02 19:05

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 c

相关标签:
2条回答
  • 2021-01-02 19:36

    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

    0 讨论(0)
  • 2021-01-02 19:40

    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.

    0 讨论(0)
提交回复
热议问题