Condividi tramite


PROPID_M_MSGID

 

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_MSGID property indicates the Message Queuing-generated identifier of the message.

Property ID

PROPID_M_MSGID

Type Indicator

VT_VECTOR | VT_UI1

MQPROPVARIANT Field

caub

Property Value

20-byte Message Queuing-generated message identifier.

Remarks

Message Queuing generates a 20-byte message identifier when the message is sent. This identifier is composed of the 16-byte globally unique identifier (GUID) of the computer that sent the message plus a 4-byte sequential number (DWORD) that uniquely identifies each message on the computer. By combining these two components, the message identifier is unique within your enterprise.

Message Queuing generates message identifiers for all messages, including acknowledgment messages generated by Message Queuing and connector applications. When an acknowledgment message is created, the identifier of the original message can be found in the PROPID_M_CORRELATIONID property of the acknowledgment message.

An SRMP message can be sent to a Message Queuing queue from a non-Message Queuing system without a message identifier. However, because Message Queuing needs this information, it adds a default message identifier to every SRMP message arriving without a message identifier. The GUID portion (16 bytes) of the default identifier equals GUID_NULL (00000000-0000-0000-0000-000000000000), and the DWORD portion (the remaining 4 bytes) equals 1.

The message identifier is an array of bytes that can be read by either the sending or receiving application. To retrieve the identifier of a message, specify PROPID_M_MSGID and a buffer consisting of 20 unsigned characters to receive its value in the MQMSGPROPS structure.

Note

The buffer must consist of exactly 20 unsigned characters. Specifying either a smaller or larger buffer will result in an error.

The size of the buffer can be specified by the constant PROPID_M_MSGID_SIZE. Then call MQSendMessage, MQReceiveMessage, or MQReceiveMessageByLookupId and examine the returned identifier.

This property can also be used when sending response messages. For example, the application creating the response message can set the correlation identifier (PROPID_M_CORRELATIONID) of the response message to the identifier of the message it read from the queue. This gives the application reading the response message a way to know which message the response is referring to.

Equivalent COM Property

With COM components, the equivalent property for retrieving the message identifier is MSMQMessage.Id.

Example Code

The following code fragment shows how PROPID_M_MSGID is specified in arrays that can be used to initialize an MQMSGPROPS structure for retrieving the identifier of a message.

UCHAR rgucMsgID[PROPID_M_MSGID_SIZE];  
aMsgPropID[i] = PROPID_M_MSGID;                 // Property ID  
aMsgPropVar[i].vt = VT_VECTOR | VT_UI1;         // Type indicator  
aMsgPropVar[i].caub.pElems = rgucMsgID;  
aMsgPropVar[i].caub.cElems = PROPID_M_MSGID_SIZE;  
i++  

The following example is included in Using Message Queuing.

For an example of See
Retrieving the message identifier when creating a response message C/C++ Code Example: Returning Response Messages

See Also

Message Properties
MQMSGPROPS
MQReceiveMessage
MQReceiveMessageByLookupId
MQSendMessage
PROPID_M_CORRELATIONID