Visual Basic Code Example: Setting MSMQQueueInfo.MulticastAddress
This example provides a private Sub procedure that sets the MSMQQueueInfo.MulticastAddress property of an existing queue based on a given multicast address. This property cannot be set for a transactional queue.
The value of this property is a string containing a valid multicast address (in the form shown below).
The address must be in the class D range from 184.108.40.206 to 220.127.116.11. However, only certain ranges of addresses in this range are unreserved and available for sending multicast messages. For the latest list of reserved multicast addresses, see the Internet Assigned Number Authority (IANA) Internet Multicast Addresses Web page. There are no restrictions on the port number.
|To disassociate an existing queue from a multicast address, set MSMQQueueInfo.MulticastAddress as follows|
qinfo.MulticastAddress = ""
Setting this property affects what messages are routed to the queue. Setting this property has no effect on messages already in the queue.
When Message Queuing updates the properties of a queue, their values are stored in one of two places. For public queues, these property values are stored in the directory service. For local private queues, these property values are stored on the local computer.
For information on how Message Queuing uses multicast addresses to send message to multiple destination queues, see Multiple-Destination Messaging.
To set MSMQQueueInfo.MulticastAddress
Declare the objects needed to update queue properties. This procedure declares an MSMQQueueInfo object.
Create the MSMQQueueInfo object. This example then uses MSMQQueueInfo.PathName to set the path name to the string passed to the function.
Optional. Call MSMQQueueInfo.Refresh to obtain the current registered settings of the queue properties. Note that this call retrieves any changes made by other applications.
Set the MSMQQueueInfo.MulticastAddress property.
Call MSMQQueueInfo.Update to register the new settings.
The following code example requires MSMQ 3.0.
Sub SetMulticastAddress( _ strPathname As String, _ strAddress As String _ ) Dim qinfo As MSMQQueueInfo ' Create the MSMQQueueInfo object. Set qinfo = New MSMQQueueInfo qinfo.PathName = strPathname On Error GoTo ErrorHandler ' Retrieve the internally registered property values. qinfo.Refresh ' Set the new queue multicast address in the MSMQQueueInfo object. qinfo.MulticastAddress = strAddress ' Update the internally registered property values. qinfo.Update MsgBox "A new multicast address was set." Exit Sub ErrorHandler: MsgBox "Error " + Hex(Err.Number) + " was returned." _ + Chr(13) + Err.Description End Sub