WCF

WCF Examples

WCF

WCF Projects

WCF Project

adplus-dvertising
Transactions in WCF
Previous Home Next

Transaction is a building robust, high-quality service-oriented applications. Transactions ensure that a group of related operations occur as a single atomic unit. In other words, every operation in the unit must either all succeed or all fail.

WCF provides simple, declarative transaction support for service developers, enabling you to configure parameters such as enlistment and voting, all outside the scope of your service.WCF provides a centralized transaction system that you can use to handle transaction operations for you.

The WCF programming model create  transactions very easy to use. You group operations into a transaction scope . This scope defines the atom of a transaction. The following pseudo code demonstrates this:

Using(TransactionScope transcope = new TransactionScope())
{
Service1.submitRequest(solution);
Service2.submitRequest(solution);
Service3.submitRequest(solution);
transcope.Complete();
}
Transactional Resources

Transactional programming needs for  working with a resource such as a database or a message queue which is provide capability of participating in a transaction, and able to commit or roll back the changes made during the transaction. Such resources have been around in one form or another for decades.

Transaction Properties:

There are four properties:

  1. The Atomic property
  2. The Consistent property
  3. The Isolated property
  4. The Durable property

1. The Atomic property: Atomicity means that all the operations must either succeed as a group or fail as a group. If one part of the transaction fails, the entire transaction fails.means that when a transaction completes, all the changes it made to the resource state must be made as if they were all one atomic, indivisible operation.

2. The Consistent property: A consistent transaction is one that, when it is complete, leaves the data store in a legal state. Legal state means that no integrity constraints are violated.Note that consistency is different from atomicity.

Even if all the changes are committed as one atomic operation, the transaction is required to guarantee that all those changes are consistent that they make sense and consistent transactions mean that the outcome is exactly what we expected it to be.

3. The Isolated property: Isolated means no other entity is able to see the intermediate state of the resources during the transaction That is, each transaction is unaware of other transactions executing concurrently in the system  because it may be inconsistent.

For a transaction to follow the isolation property, the changes that are part of the transaction should not be available until the transaction is complete.

4. The Durable property: A transaction must survive failure to be called as durable. Once the transaction is committed, any kind of failure that might affect the data store should not affect it.durability is really a range of options.

How resilient to such catastrophes the resource should be is an open question that depends on the nature and sensitivity of the data,

Previous Home Next