Gets or sets the message priority, used to determine where the message is placed in the queue.
[Visual Basic] Overridable Public Property Priority As MessagePriority [C#] public MessagePriority Priority {virtual get; virtual set;} [C++] public: __property virtual MessagePriority get_Priority(); public: __property virtual void set_Priority(MessagePriority); [JScript] public function get Priority() : MessagePriority; public function set Priority(MessagePriority);
One of the MessagePriority values that represents the priority level of a non-transactional message. The default is Normal.
Exception Type | Condition |
---|---|
InvalidOperationException | The message queue is filtered not to read the Priority property. |
Priority affects how Message Queuing handles the message while it is in route, as well as its place in the queue. High priority messages are given preference during routing, and inserted toward the front of the queue. Messages of equal priority are placed in the queue according to their arrival time.
Priority provides access to the Priority property of the Message Queuing MSMQMessage object.
Priority can only be set for non-transactional messages, because Priority for transactional message is automatically set to 0.
The following example creates an empty message. The example populates the Message with a string Body, sets the Priority property, and then sends the message to a queue. It assumes there is a queue on the computer "myComputer" with the name "myQueue".
Import the System.Messaging namespace for this example.
[Visual Basic]
Private Sub CreateMessage() 'Declare a message and message queue Dim msg As Message Dim mq As MessageQueue 'Instantiate an empty message object msg = New Message 'Instantiate a new MessageQueue object mq = New MessageQueue("myComputer\myQueue") 'Set selected message properties. msg.Priority = MessagePriority.Highest msg.Body = "New Message Body" 'Send the message to the queue. mq.Send(msg) End Sub
Message Class | Message Members | System.Messaging Namespace | MessagePriority | MessageType | BasePriority