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.Category

Gets or sets the queue type.

[Visual Basic]
Overridable Public Property Category As Guid
[C#]
public Guid Category {virtual get; virtual set;}
[C++]
public: __property virtual Guid get_Category();
public: __property virtual void set_Category(Guid);
[JScript]
public function get Category() : Guid;
public function set Category(Guid);

Property Value

A Guid that represents the queue category (Message Queuing type Id). The default is Guid.empty.

Exceptions

Exception Type Condition
ArgumentException The queue category was set to an invalid value.
MessageQueueException The attempt to get or set the queue category generated an internal error on the message queue component. The error is specified by the given status message.

Remarks

The queue category enables an application to categorize associated queues according to the way they are used. The Category can be a null reference. You can also define a new 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}.

Id and Category are both Guid values. However, their behavior is quite different. The Category is a read/write value, while Id is read-only. Also, the Category need not be unique on the network. You can, for example, define all Billing queues to have the same category, and all Order queues to have a different category. The Id values for each queue on the network are guaranteed to be unique when the Message Queuing application creates the queue

Example [Visual Basic]

The following example creates a list of queues associated with a specified category. A queue is passed in by its Path property. The procedure retrieves the Category for that queue and sends a broadcast message to all other queues with the same Category.

This procedure required that a path be passed in. Because GetPublicQueuesByCategory retrieves only public queues, it is assumed that the path is in the form "computer name\queue name". It is also assumed that the category (Message Queuing type id) associated with the queue is not a null reference (in Visual Basic Nothing).

[Visual Basic]

Private Sub SearchPublicQueuesByCategory(ByVal queuePath As String)
    '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
    'The category of the queue with the specified path.
    Dim cat As System.Guid

    'Define and instantiate a new MessageQueue with the specified path.
    Dim MessageQueue1 As MessageQueue
    MessageQueue1 = New MessageQueue(queuePath)

    'Get the category of the queue that was passed in.
    cat = MessageQueue1.Category

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

    'Iterate through the message queues to send a message to each one.
    For i = 0 To mqList.Length - 1
        'There may be several machines containing queues with 
        'the given category. Send a message to each one    
        mqList(i).Send("Broadcast message to queues with category " + cat.ToString)
        'Send notification about the queue and its index in the array.
        MessageBox.Show(mqList(i).Path + " at index: " + i)
    Next
End Sub

See Also

MessageQueue Class | MessageQueue Members | System.Messaging Namespace | Id | TBD | Label | GetPublicQueuesByCategory | GetPublicQueues