I am trying to use MessageQueues to notify users of an application of data changes using the Multicast feature, but can't get it to work : the workstation that sends the message does receive it, but none of the other running workstations seem to catch the sent message.
Sending messages is done as follows :
Dim sendQueue As New Messaging.MessageQueue("FormatName:MULTICAST=234.1.1.1:8001")
Dim message As New Messaging.Message("message body...")
sendQueue.Send(message)
And receiving them :
Dim receiveQueue As New Messaging.MessageQueue(".\private$\myQ")
receiveQueue.MulticastAddress = "234.1.1.1:8001"
receiveQueue.BeginReceive()
AddHandler receiveQueue.ReceiveCompleted, Sub(sender As Object, e As Messaging.ReceiveCompletedEventArgs)
' ... handle message
receiveQueue.BeginReceive()
End Sub
So I'm obviously missing something, and I can't seem to find any good resources on multicasting with MSMQ 3.0 in .NET.
Also, what is not clear is whether I should use a local queue per workstation, or one single remote queue on a server to multicast messages ? And does using the receive method on multicast messages purge them from the queue?
Any help, hints, tips, suggestions, anything... will be greatly welcome.
On a side note, all workstations are on the same subnet, and all have MSMQ 3.0 installed.
The final word
Well thank you laptop for your help. The issue was actually related to permissions as I discovered while testing your solution with COM objects :
Despite what the Queue properties dialog says, permissions are NOT totally ignored on unauthenticated queues, at least when using multicasting. If you want your queue to receive multicast messages, it must give to 'ANONYMOUS_LOGON' the right to 'Send messages'. Otherwise, multicast messages are just discarded without any notice in event logs or whatsoever (unless I missed something).
On Win7 stations (XP stations seem to do fine, which is what pointed me to the actual problem), queues created through code do not have such permissions, and hence must be manually set after creating the queue :
Dim msgQ = Messaging.MessageQueue.Create(queueName)
msgQ.SetPermissions("ANONYMOUS LOGON",
Messaging.MessageQueueAccessRights.WriteMessage)
It would seem that internally, MSMQ uses that account to write multicast messages to unauthenticated queues.