共用方式為


PROPID_M_FIRST_IN_XACT

 

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

(Read-only, introduced in MSMQ 2.0.) The PROPID_M_FIRST_IN_XACT property indicates whether the message was the first message sent in a transaction.

Property ID

PROPID_M_FIRST_IN_XACT

Type Indicator

VT_UI1

MQPROPVARIANT Field

bVal

Property Value

One of the following:

MQMSG_FIRST_IN_XACT

The message was the first message sent in the transaction.

MQMSG_NOT_FIRST_IN_XACT

The message was not the first message sent in the transaction.

Remarks

This property is available for MSMQ 2.0 and later. It is used by receiving applications to verify that a message was the first message sent in a single transaction to a single queue.

You can use PROPID_M_FIRST_IN_XACT along with two other properties to verify transaction boundaries. The PROPID_M_LAST_IN_XACT property is used for identifying the last message sent in the transaction, and the PROPID_M_XACTID property is used for retrieving the identifier of the transaction.

If only one message is sent in a transaction, both PROPID_M_FIRST_XACT and PROPID_M_LAST_XACT are set.

To retrieve this property, include PROPID_M_FIRST_IN_XACT in the MQMSGPROPS structure. Then call MQReceiveMessage or MQReceiveMessageByLookupId and test the returned value. 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 for ascertaining whether a message is the first message in a transaction is MSMQMessage.IsFirstInTransactionansaction.

For information on See
How transaction boundaries can be used Checking for Transaction Boundaries when Receiving Messages
Identifying the last message in the transaction PROPID_M_LAST_IN_XACT
Retrieving the identifier of the transaction PROPID_M_XACTID

Example Code

The following code fragment shows how PROPID_M_FIRST_IN_XACT is specified in arrays that can be used to initialize an MQMSGPROPS structure.

aMsgPropId[i] = PROPID_M_FIRST_IN_XACT; // Property ID  
aMsgPropVar[i].vt = VT_NULL;            // Type indicator  
i++;  

The following example is included in Using Message Queuing.

For an example of See
Identifying the first and last messages in a transaction C/C++ Code Example: Checking Transaction Boundaries

See Also

Message Properties
MQMSGPROPS
MQReceiveMessage
MQReceiveMessageByLookupId
MQSendMessage
PROPID_M_LAST_IN_XACT
PROPID_M_XACTID