Developing Caching Resource Managers
When an application program invokes the caching resource manager, the caching resource manager retrieves the requested information from its local cache, if possible, or alternatively, from the underlying resource manager. If the application performs an update, the updated data is stored only in the local cache, allowing the caching resource manager to avoid sending unnecessary messages to the underlying resource manager. The caching resource manager uses the DTC phase zero interfaces to receive notification of any impending transaction commits. This permits the caching resource manager to send its cached updates to the underlying resource manager just before the start of the two-phase commit protocol.
The phase zero notification mechanism uses the following interfaces:
ITransactionPhase0EnlistmentAsync—Indicates the completion of all phase zero processing or that it is no longer interested in phase zero notifications.
ITransactionPhase0Factory—Exports a method to create a phase zero enlistment object in the DTC proxy and exchange.
ITransactionPhase0NotifyAsync—Notifies phase zero participants of the phase zero event.
The phase zero notification interfaces allow applications to detect when a transaction is ready to proceed with a two-phase commit protocol so that they can perform such operations and communicate to the transaction manager when they are completed.
Certain distributed transaction applications require a mechanism by which they can learn that a transaction is ready to enter the prepare state of the two-phase commit protocol. For example, an application that participates in a transaction might possess data that has been modified but not yet written to stable storage. If the application is not capable of providing the durability guarantees required by transactions (for example, by acting as a resource manager and participating in the two-phase commit process and recovery), it must ensure that it has flushed all modified data to a full-service resource manager before the two-phase commit protocol is initiated.
The phase zero notification mechanism is provided by phase zero enlistment objects and phase zero notification objects. These objects implement the ITransactionPhase0EnlistmentAsync and ITransactionPhase0NotifyAsync interfaces, respectively. The former is implemented by the DTC proxy, and the latter is implemented by the application that needs to participate in phase zero notification. Both interfaces are exchanged as sinks when a phase zero enlistment object is created.