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

Gets the Message Queuing unique identifier for the queue.

[Visual Basic]
Overridable Public ReadOnly Property Id As Guid
[C#]
public Guid Id {virtual get;}
[C++]
public: __property virtual Guid get_Id();
[JScript]
public function get Id() : Guid;

Property Value

An Id that represents the Message Queuing application-generated message identifier.

Exceptions

Exception Type Condition
MessageQueueException The attempt to get the id generated the exception specified by the given information.

Remarks

The Id property is set by the Message Queuing application when the application creates the queue.

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 uses the queue Id to set the Path property. Because Id is read-only, the procedure does not set the Id property, but it can be read and appended to the string "FormatName:Public=" in order to define the path. This procedure assumes that the Id passed in represents a valid public queue.

The function GetQueueId gets the Id from a known queue.

[Visual Basic]

Private Sub SendUsingQueueFormat(ByVal queueId As System.Guid)
    'The queue path, to be generated from the queue Id.    
    Dim queuePath As String
    'Define a new MessageQueue.
    Dim messageQueue1 As MessageQueue

    'Generate the path using the FormatName.
    queuePath = "FormatName:PUBLIC=" + queueId.ToString
    'Instantiate a MessageQueue with the specified path.
    messageQueue1 = New MessageQueue(queuePath)
    'Send a message to the queue.   
    messageQueue1.Send("Test Message")
End Sub

Private Function GetQueueId(ByVal queuePath As String) As System.Guid
    Dim idGuid As System.Guid
    'Create and instantiate a MessageQueue using the path passed in.
    Dim mq As MessageQueue
    mq = New MessageQueue(queuePath)
    'Return the Id of the queue to the calling procedure.  
    GetQueueId = mq.Id
End Function

See Also

MessageQueue Class | MessageQueue Members | System.Messaging Namespace | Category | TBD