Microsoft KB Archive/307415

= INFO: How Multiple Components Participate and Vote in a Single Transaction =

Article ID: 307415

Article Last Modified on 12/5/2007

-

APPLIES TO


 * Microsoft COM+ 1.0
 * Microsoft COM+ 1.5
 * Microsoft Transaction Services 2.0, when used with:
 * Microsoft Windows NT 4.0

-



This article was previously published under Q307415



SUMMARY
This article describes the behavior of COM+ and Microsoft Transaction Server (MTS) when multiple objects participate in a single transaction. This article also describes how to code these components correctly to avoid the CONTEXT_E_ABORTING (or mtsErrCtxAborting) error with HRESULT 0x8004E003 or -2147164157.



MORE INFORMATION
In MTS and COM+, you can use two Boolean flags, HAPPY and DOOMED, to determine the outcome of a transaction.

Each transactional MTS object stores one HAPPY flag in the context. Conversely, the whole transaction contains only one DOOMED flag, regardless of the number of objects in that transaction. The DOOMED flag has an initial value of FALSE.

The base client calls a transactional component (the root component) that starts the transaction. The root component then creates instances of the secondary transactional components. The secondary transactional components, in turn, create instances of the tertiary transactional components, and so on. In the method call of a transactional component, you can set the value of the HAPPY flag for that component to TRUE (to call the SetComplete method) or to FALSE (to call the SetAbort method). The DisableCommit or the EnableCommit method may also affect the method call of a transactional component. The final value of the HAPPY flag depends on the final call to SetAbort or to SetComplete and whether that call is explicit or implicit. The flag contains an initial value of TRUE.

When the method call is returned, the transactional component is deactivated. When the transactional component is deactivated, COM+ inspects the HAPPY flag that is associated with the component. If you set a HAPPY flag to FALSE, the DOOMED flag changes to TRUE. After you set the value of the DOOMED flag to TRUE, you cannot set the value to FALSE. Therefore, if any transactional component calls SetAbort before the component returns, explicitly or implicitly, the transaction aborts, regardless of how other components vote in the transaction. When the root component returns, the transaction aborts.

NOTE: The transaction does not immediately abort. The transaction aborts when the root component deactivates. Therefore, incomplete method calls may exist after you set the DOOMED flag of the transaction to TRUE.

You can code the components in such a way that they convey to the caller whether the components call SetComplete or SetAbort before the components return. If the caller detects that a child component calls SetAbort, the caller must stop any processing, call SetAbort, and then return. The work that is in progress at this time is rolled back.

COM+ cannot always detect if more work occurs after the transaction aborts. COM+ does detect any newly activated transactional components in the transaction. COM+ returns the CONTEXT_E_ABORTING error if newly activated transactional components exist in the transaction. This error returns as the HRESULT of the function call that tries to activate the component.

Additional query words: instantiate

Keywords: kbinfo KB307415

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.