Enlisting in New Transactions

The resource manager can start enlisting in new transactions after it establishes a relationship with MS DTC. The resource manager then obtains an ITransaction interface to a transaction and enlists in this transaction by invoking the IResourceManager::Enlist method. One of the parameters to this method is an instance of ITransactionResourceAsync. Once the resource manager has enlisted in a transaction, it is expected to participate in the two-phase commit protocol. When the initiator of the transaction invokes the ITransaction::Commit method, MS DTC initiates the voting phase of the two-phase commit protocol. The first phase notifications are delivered to each participant (such as a resource manager) that is enlisted in the transaction. This notification is delivered by invoking the ITransactionResourceAsync::PrepareRequest method. The resource manager then performs the relevant work to move from an active state to a prepared state and on moving to the prepared state invokes the ITransactionEnlistementAsync::PrepareRequestDone method. Similarly, the decision phase notification is provided to each enlisted participant by the invocation of the ITransactionResourceAsync::CommitRequest method. A resource manager responds to this notification by invoking the ITransactionEnlistment::CommitRequestDone method. The Abort notification also works the same way as the first phase notification. However, there is no second phase in the case of an Abort.

A resource manager can obtain the ITransaction interface for enlistment in the following ways:

  1. A resource manager can initiate a transaction. The resource manager obtains the MS DTC transaction by invoking the ITransactionDispenser::BeginTransaction method.
  2. An in-process application component can initiate a transaction. See the Transaction Initiated by an In-Process Component topic for more information.
  3. Propagation of a transaction. See the Transaction Propagation topic for more information