PROPID_M_PRIORITY

 

Applies To: Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2, Windows Server Technical Preview, Windows Vista

The PROPID_M_PRIORITY property specifies the priority of the message. A lower number means a lower-priority message.

Property ID

PROPID_M_PRIORITY

Type Indicator

VT_UI1

MQPROPVARIANT Field

bVal

Property Value

An integer value between 7 and 0 (the default is 3).

Remarks

Message priority affects how Message Queuing handles the message while it is in route, as well as where the message is placed in the queue. Higher-priority messages are given preference during routing, and inserted toward the front of the queue. For example, when routing messages, Message Queuing handles messages with a priority of 7 before it handles messages with a priority of 0, and when the message is delivered to the destination queue, Message Queuing places the priority 7 messages closer to the front of the queue.

Messages with the same priority are placed in the queue according to their arrival time.

When Message Queuing routes a message to a public queue, the priority level of the message is added to the priority level of the public queue (the priority level of the queue is specified by the PROPID_Q_BASEPRIORITY property of the queue). Message Queuing uses this combined priority for routing only. The priority level of the queue has no effect on the order in which messages are placed in the queue.

Message Queuing automatically sets the priority level of transactional messages to 0: PROPID_M_PRIORITY is ignored by the transaction.

To specify the priority level of a message, include PROPID_M_PRIORITY in the MQMSGPROPS structure and then call MQSendMessage.

To retrieve the priority level specified by the sending application, include PROPID_M_PRIORITY in the MQMSGPROPS structure, then call MQReceiveMessage or MQReceiveMessageByLookupId and examine the returned values. When retrieving this property, the type indicator can be set to VT_UI1 or VT_NULL. If you set the type indicator to VT_NULL, Message Queuing automatically changes the type indicator to VT_UI1 during the function call.

Equivalent COM Property

With COM components, the equivalent property is MSMQMessage.Priority.

Example Code

The following code fragments show how PROPID_M_PRIORITY is specified in arrays that can be used to initialize an MQMSGPROPS structure for setting and retrieving the priority level of the message.

To Set the Priority Level

aMsgPropID[i] = PROPID_M_PRIORITY;          // Property ID  
aMsgPropVar[i].vt = VT_UI1;                 // Type indicator  
aMsgPropVar[i].bVal = 7;  
i++;  

To Retrieve the Priority Level

aMsgPropID[i] = PROPID_M_PRIORITY;          // Property ID  
aMsgPropVar[i].vt = VT_NULL;                // Type indicator  
i++;  
For information on See
How messages are sent and retrieved in transactions Transactions

See Also

Message Properties
MQMSGPROPS
MQReceiveMessage
MQReceiveMessageByLookupId
MQSendMessage
PROPID_Q_BASEPRIORITY