NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

MessageQueue.GetPublicQueuesByCategory

Retrieves a set of public queues filtered by the specified category.

[Visual Basic]
Public Shared Function GetPublicQueuesByCategory( _
   ByVal category As Guid _
) As MessageQueue ()
[C#]
public static MessageQueue[] GetPublicQueuesByCategory(
   Guid category
);
[C++]
public: static MessageQueue* GetPublicQueuesByCategory(
   Guid category
) [];
[JScript]
public static function GetPublicQueuesByCategory(
   category : Guid
) : MessageQueue[];

Parameters

category
Specifies the category that will be used to filter the queues in the network.

Return Value

An array of MessageQueue objects that reference the public queues retrieved.

Remarks

Use this method to filter public queues by category. The Category property provides access to the Message Queuing queue-associated type ID read/write property. You can use NewGuid to create a category value that is guaranteed to be unique across all Guid values. However, it is only necessary for the category value to be distinct from other categories, not from all other Guid values. You may assign, for example, the Category for one set of queues to be {00000000-0000-0000-0000-000000000001} and the Category for another set of queues to be {00000000-0000-0000-0000-000000000002}.

GetPublicQueuesByCategory retrieves a static snapshot of the queues. To interact with a dynamic queue list, use GetMessageQueuesEnumerator. You can specify the category as part of the MessageQueueCriteria passed in.

GetPublicQueuesByCategory can not be used to retrieve private or system queue information.

GetPublicQueuesByCategory is a static (in Visual Basic Shared) member, so it can be called using the MessageQueue class itself. It is not necessary to create an instance of MessageQueue in order to call the method.

Example [Visual Basic]

The following example creates a list of queues associated with a specified category. The procedure retrieves the Category for a queue named "myComputer\myQueue" and sends a broadcast message to all other queues with the same Category.

This procedure assumes that the queue "myQueue" exists on the computer "myComputer". It is also assumed that the category associated with the queue is not a null reference (in Visual Basic Nothing).

[Visual Basic]

Private Sub SearchPublicQueuesByCategory()
    'Create an array to hold the set of message queues.
    Dim mqList() As MessageQueue
    'The following integer is used in the for loop.
    Dim i As Integer
    Dim category As System.Guid

    'Define a MessageQueue.
    Dim messageQueue1 As MessageQueue
    'Connect the MessageQueue to the specified queue.
    messageQueue1 = New MessageQueue("myComputer\myQueue")
    'Get the category of the queue.
    category = MessageQueue1.Category

    'Get an array containing messagequeue information.
    mqList = MessageQueue.GetPublicQueuesByCategory(category)

    'Iterate through the message queues; this may involve several computers.
    For i = 0 To mqList.Length - 1
        'Send a message to each queue in the category.    
        mqList(i).Send("Broadcast message to queues with category " + category.ToString)
    Next
End Sub

See Also

MessageQueue Class | MessageQueue Members | System.Messaging Namespace | Category | GetPublicQueues | GetPublicQueuesByLabel | GetPublicQueuesByMachine