What is MSDTC and why do I need to care about it?

I've been talking for a while about MSDTC and transactions without explaining them. I know many of you reading this blog already know the terms, but some of the developers just entering the enterprise space don't know if they should care or not about these subjects.

MSDTC is an acronym for Microsoft Distributed Transaction Coordinator. As the name says, MSDTC is a Windows service providing transaction infrastructure for distributed systems. In this case, a transaction means a general way of structuring the interactions between autonomous agents in a distributed system. Each transaction is a state transformation with four key properties - the ACID properties: Atomic (all or nothing), Consistent (legal), Isolated (independent of concurrent transactions) and Durable (once it happens, it cannot be abrogated). There are different techniques that implement the ACID properties but the most known one is two-phase commit.

In other words, transaction processing is a software technology that makes distributed computing reliable. You can see a transaction as a unit of work in which a series of operations occur. The transaction (with its ACID properties) is providing protection in the case when one or more of these operations fail at any point in time. By using transactions, you can vastly simplify the error recovery for your system.

The main actors in a transaction are: the transaction manager (MSDTC), the initiator (the application which started the transaction) and the resource managers (the entities that manage data and work). The flow of actions in a simplified form is:

1. The client application (the initiator) begins a transaction by requesting one from the transaction manager;

2. The client app asks the resource managers to do work as part of the same transaction; during this step, the resource managers register with the transaction manager for that transaction ("they enlist");

3. The client app commits the transaction;

4. The transaction manager coordinates with the resource managers to ensure that all succeed to do the requested work or none of the work if done, thus maintaining the ACID properties.

The main transactions standard currently supported by MSDTC is the OLE Transactions (or OleTx). MSDTC is also supporting other standards like XA (or X/Open Distributed Transaction Processing Standard) and TIP (Transaction Internet Protocol). In the future MSDTC will support WS-Coordination, WS-AtomicTransaction, and WS-BusinessActivity.

You can read more about MSDTC at https://msdn.microsoft.com/library/?url=/library/en-us/cossdk/htm/dtc_toplevel_6vjm.asp?frame=true.

If you are developing COM+ or System.EnterpriseServices components and you are using the Transaction service then you are indirectly using MSDTC. The COM+ infrastructure is hiding all the details from you so you can focus on your business needs instead of implementation details. If you need to bypass COM+ and talk directly to MSDTC you can do it using the MSDTC proxy (msdtcprx.dll). For now, to directly access MSDTC from .Net apps you need to use COM Interop. For future apps, please refer to my previous post about .Net and Transactions.