Gets or sets the message label.
[Visual Basic] Public Property Label As String [C#] public string Label {get; set;} [C++] public: __property String* get_Label(); public: __property void set_Label(String*); [JScript] public function get Label() : String; public function set Label(String);
The label of the message. The default is an empty string.
Label provides access to the Label property of the Message Queuing application's MSMQMessage object.
The following example demonstrates defining different DefaultPropertiesToSend based on whether a message passed into the procedure has highest or normal MessagePriority. The properties that are set, which apply to the message to be sent to the message queue, are the Label, the Priority, the TimeToBeReceived, and the TimeToReachQueue. It is important to note that these properties are set through the MessageQueue, but they apply to the Message object.
This example assumes that the calling procedure passes in a MessagePriority, and that an urgent message is indicated by Highest priority. It also assumes that the calling method defines the Message that is to be sent to the queue.
[Visual Basic]
Private Sub SetDefaultPropertiesToSend(ByVal urgency As MessagePriority, ByVal msg As System.Messaging.Message) 'Create DefaultPropertiesToSend objects Dim urgentMessageProperties As DefaultPropertiesToSend Dim normalMessageProperties As DefaultPropertiesToSend 'Define and instantiate a new MessageQueue object Dim MessageQueue1 As System.Messaging.MessageQueue.MessageQueue Set Me.MessageQueue1 = New System.Messaging.MessageQueue 'Set the queue formatter to the XML-based formatter Set MessageQueue1.Formatter = New System.Messaging.XmlQueueMessageFormatter Set MessageQueue1.DefaultPropertiesToSend.UseDeadLetterQueue = True 'Set the label for the queue (as opposed to the message labels). Set MessageQueue1.Label = "Order Queue" 'Set the queue path MessageQueue1.Path = "mycomputer\myqueue" 'Instantiate two new DefaultPropertiesToSend objects Set urgentMessageProperties = New DefaultPropertiesToSend Set normalMessageProperties = New DefaultPropertiesToSend 'Set the label and priority for urgent messages urgentMessageProperties.Label = "Urgent Message" urgentMessageProperties.Priority = MessagePriority.Highest 'Make the process wait indefinitely for a message. urgentMessageProperties.TimeToBeReceived = Message.InfiniteTimeout urgentMessageProperties.TimeToReachQueue = Message.InfiniteTimeout urgentMessageProperties.UseDeadLetterQueue = True 'set the label and priority for normal messages normalMessageProperties.Label = "Normal Message" normalMessageProperties.Priority = MessagePriority.Normal 'Make the process wait a finite amount of time for a message. normalMessageProperties.TimeToBeReceived = 3000 normalMessageProperties.TimeToReachQueue = 3000 normalMessageProperties.UseDeadLetterQueue = True 'If the message is urgent, use the urgent DefaultPropertiesToSend If urgency = MessagePriority.Highest Then Set MessageQueue1.DefaultPropertiesToSend = urgentMessageProperties Else 'Otherwise, use normal DefaultPropertiesToSend Set MessageQueue1.DefaultPropertiesToSend = normalMessageProperties End If 'Override default properties on the message object msg.Priority = MessageQueue1.DefaultPropertiesToSend.Priority msg.Label = MessageQueue1.DefaultPropertiesToSend.Label msg.TimeToBeReceived = MessageQueue1.DefaultPropertiesToSend.TimeToBeReceived msg.TimeToReachQueue = MessageQueue1.DefaultPropertiesToSend.TimeToReachQueue 'Send the message that was passed in. MessageQueue1.Send msg 'Display Label and MessagePriority information on the screen MessageBox.Show MessageQueue1.DefaultPropertiesToSend.Label & ". Priority: " & MessageQueue1.DefaultPropertiesToSend.Priority End Sub
DefaultPropertiesToSend Class | DefaultPropertiesToSend Members | System.Messaging Namespace | TBD