This is preliminary documentation and subject to change. To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!
Retrieving Queues
You can use either static or dynamic retrieval mechanisms to retrieve a list of queues. When you retrieve a static list of queues, a MessageQueue object is returned with the results of your query. When you retrieve a dynamic list of queues, a MessageQueuesEnumerator object is returned with the results of the query.
Because the GetPublicQueues, GetPrivateQueues, and GetMessageQueuesEnumerator methods are static, you do not need to create an instance of an instance of the MessageQueue class before calling the method.
To retrieve a static list of public queues
Create an array that references the MessageQueue object to hold the results of your query.
Call the appropriate method on the MessageQueue class:
To retrieve all public queues without criteria, call GetPublicQueues.
To retrieve public queues with criteria, set the Criteria parameter to the appropriate value and call GetPublicQueues.
To retrieve only those public queues that share a category GUID, call GetPublicQueuesByCategory and specify the category GUID as the parameter.
To retrieve only those public queues that share a label, call GetPublicQueuesByLabel and specify the label as a parameter.
To retrieve only those public queues on a specific machine, call GetPublicQueuesByMachine and specify the machine name as a parameter.
Assign the results to the array. Your code might look like this:
[Visual Basic]
Sub Main
'Create an array to hold the set of message queue objects
Dim mqlist() As MessageQueue
'Get an array containing messagequeue information
mqlist = MessageQueue.GetPublicQueuesByMachine("machinename")
End Sub
[C#]
public void Main() {
// Create an array to hold the set of message queue objects
MessageQueue[] mqlist();
// Get an array containing messagequeue information
mqlist = MessageQueue.GetPublicQueuesByMachine("machinename");
}
To retrieve a static list of private queues
Create an array that references the MessageQueue object to hold the results of your query.
Call the GetPrivateQueuesbyMachine method, specifying the machine on which the queues exist as a parameter.
Assign the results to the array. Your code might look like this:
[Visual Basic]
Sub Main
'Create an array to hold the set of message queue objects
Dim mqlist() As MessageQueue
'Get an array containing messagequeue information
mqlist = MessageQueue.GetPrivateQueuesByMachine("machinename")
End Sub
[C#]
To retrieve a dynamic list of queues
Create a MessageQueuesEnumerator object to hold the results of your query.
Call the GetMessageQueuesEnumerator method on the MessageQueue class.
To retrieve a subset of the queues on the network, set the Criteria parameter to the appropriate value.
Set the results to the MessageQueuesEnumerator object you created. Your code might look like this:
[Visual Basic]
Sub main()
'Create an enumerator to hold the set of message queue objects
Dim mqEnum as MessageQueuesEnumerator
'Get the queues
mqEnum = MessageQueue.GetMessageQueuesEnumerator()
End Sub
[C#]