Gets or sets the queue description.
[Visual Basic] Overridable Public Property Label As String [C#] public string Label {virtual get; virtual set;} [C++] public: __property virtual String* get_Label(); public: __property virtual void set_Label(String*); [JScript] public function get Label() : String; public function set Label(String);
The label for the message queue. The default is an empty string ("").
Exception Type | Condition |
---|---|
ArgumentException | The label was set to an invalid value. |
MessageQueueException | The attempt to get or set the label generated an internal error on the message queue component. The error is specified by the given status message. |
The maximum length of a message label is 250 Unicode characters (including the end-of-line character).
The Label property does not have to be unique across queues. However, the Label cannot be used to broadcast messages to multiple queues using the Send method. If you call Send and pass in a Label for the Path property, an exception will be thrown if the Label is not unique.
The following example connects to a queue by specifying the Label property. Because the MachineName is not specified, the computer is the local computer. If no queue with the label exists, one is created.
It is assumed that the label parameter passed in was defined within the calling procedure.
[Visual Basic]
Private Sub CreateQueueByLabel(ByVal label As String) 'Define a new MessageQueue Dim messageQueue1 As MessageQueue 'If a queue with the given label doesn't exist, create it. If Not MessageQueue.Exists("Label:" + label) Then messageQueue1 = MessageQueue.Create("Label:" + label) 'Set the label for the queue. messageQueue1.Label = label End If End Sub
MessageQueue Class | MessageQueue Members | System.Messaging Namespace | Path | FormatName | MessageQueue | GetPublicQueuesByLabel | GetPublicQueues