Compartilhar via


MSMQMessage.Id

 

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 Id property of the MSMQMessage object identifies the message using an MSMQ-generated message identifier.

Data type: Variant (array of bytes)
Run-time access: Read-only
Property Id As Variant  

Property Value

A Variant (array of bytes) specifying a 20-byte message identifier.

Remarks

Message Queuing generates a 20-byte message identifier when the message is sent. This includes application-generated messages sent by applications and system-generated messages sent by Message Queuing. The message identifier is composed of the 16-byte globally unique identifier (GUID) of the sending computer and the 4-byte sequential number (DWORD) of that particular message on the sending computer. By combining these two components, the message identifier is unique within your enterprise.

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.

When messages are sent to multiple destinations by means of distribution lists, multicast addresses, and multiple-element format names, only one identifier is generated for all the messages sent. For example, if a distribution list is used to send a message to three destinations all three messages will have the same message identifier. To distinguish between messages with the same identifier, the application looking at the messages must also check the unique destination of each message.

When an acknowledgment message is created, the message identifier of the original message can be found in the MSMQMessage.CorrelationId property of the acknowledgment message.

When sending response messages, MSMQMessage.CorrelationId can be set to the message identifier of the message that is in the queue. This provides an easy mechanism that the sending application can use to match the response message with the message that was sent.

When dimensioning arrays for the message identifier, always set the lower boundary of the array to 0. When filling in the identifier, Message Queuing sets the lower boundary of the returned byte-array to 0 regardless of what boundary was set by the application.

The following Visual Basic® call will always return 0.

LBound
(msg.Id)  

Equivalent API Function Property

With API function calls, the equivalent property is PROPID_M_MSGID.

Example Code

The following example is included in Using Message Queuing.

For an example of See
Retrieving the destination queue of a message when returning response messages Visual Basic Code Example: Returning Response Messages

Requirements

Windows NT/2000/XP: Included in Windows NT 4.0 SP3 and later.

Windows 95/98/Me: Included in Windows 95 and later.

Header: Declared in Mqoai.h.

Library: Use Mqoa.lib

See Also

MSMQMessage
MSMQMessage.CorrelationId
PROPID_M_MSGID