3.3.4.8 Xa_prepare
The Xa_prepare event MUST be signaled with the following arguments:
XID - XA Transaction Branch Identifier.
RMID - Resource Manager ID.
Flags - Flags defined in [XOPEN-DTP] Chapter 4.4 and section 3.3.1.2 of this document.
The Xa_prepare event MUST return the following value:
XA Result - Return code defined in [XOPEN-DTP] Chapter 4.5.
If the Xa_prepare event is signaled, the XA Superior Transaction Manager MUST perform the following actions:
If the provided Flags field has TMASYNC set:
Return XAER_ASYNC.
Otherwise:
Attempt to find an XA Superior Proxy object in the XA Superior Proxy Table keyed by the provided RMID.
If an object is not found:
Return XAER_RMFAIL.
Otherwise:
Attempt to find an XA Transaction Object in the XA Transaction Table referenced by the XA Superior Proxy object keyed by the provided XID.
If an object is found:
Use this as the XA Transaction.
Otherwise:
Attempt to create a new XA Transaction Object with the following values:
The XID field is set to the provided XID.
The Thread Identifier field is set to the Current Thread ID.
The Migrate field is set to FALSE.
The State field is set to Suspended.
If the provided Flags field has TM_NOTHREADAFFINITY set:
Set Require Thread Affinity field to TRUE.
Otherwise:
SHOULD set Require Thread Affinity field to FALSE.<20>
The Parent XA Superior Proxy object is set to the found XA Superior Proxy object.
If failed:
Return XAER_RMERR.
Otherwise:
Use this as the XA Transaction Object.
If the found XA Superior Proxy object has the Branch Isolation field set to Tight:
Attempt to create a new XA Transaction CMP Connection with the following values:
The Connection Type field is set to CONNTYPE_XAUSER_XACT_BRANCH_OPEN.
The XA Transaction Object is set to the created XA Transaction Object.
The State field is set to Awaiting Open Response.
The State field of the XA Transaction Object is set to Opening.
The Action field is set to Prepare.
If failed:
Return XAER_RMERR.
Send an XAUSER_XACT_MTAG_OPEN message with the following values:
The guidXaRm field set to the Resource Manager Recovery GUID field of the found XA Superior Proxy object.
The lenXAIdentifier field of the XA_UOW structure (section 2.2.1.4) in the XAUow field set to the size of an XA_XID structure (section 2.2.1.3).
The XAIdentifier field of the XA_UOW structure in the XAUow field set to the provided XID field.
Wait for a response and continue with the processing rules defined in CONNTYPE_XAUSER_XACT_BRANCH_OPEN Initiator (section 3.3.5.6).
Otherwise:
Attempt to create a new XA Transaction CMP Connection object with the following values:
The Connection Type is set to CONNTYPE_XAUSER_XACT_OPEN.
The XA Transaction Object is set to the previously found or created XA Transaction Object.
The State field is set to Awaiting Open Response.
The Action field is set to Prepare.
If failed:
Return XAER_RMERR.
Set the State field of the XA Transaction Object to Opening.
Send an XAUSER_XACT_MTAG_OPEN message with the following values:
The guidXaRm field set to the Resource Manager Recovery GUID field of the found XA Superior Proxy object.
The lenXAIdentifier field of the XA_UOW structure in the XAUOW field set to the size an XA_XID structure.
The XAIdentifier field of the XA_UOW structure in the XAUOW field set to the provided XID field.
Wait for a response and continue with the processing rules defined in CONNTYPE_XAUSER_XACT_OPEN Initiator (section 3.3.5.3).