Chapter 8: Supporting Transactions


Overview

After completing this chapter, you will be able to:

  • Describe the transaction management protocols available with WCF.

  • Use transactions with WCF services and operations.

  • Explain how to implement secure, distributed transactions by using the WS-AtomicTransaction protocol.

  • Describe the impact that using transactions can have on the design of a WCF service.

A common requirement of most applications is the need to ensure internal consistency in the data that they manipulate. You can use transactions to help achieve this aim. A transaction is an atomic unit of work or a series of operations that should either all be performed or, if something unexpected happens, all be undone. The classic example of a transaction concerns the transfer of funds between two bank accounts, comprising the deduction of an amount of money from one account and an equivalent addition to the other account. If the addition operation fails, then the deduction operation must be undone, otherwise the money is lost (and the bank risks losing its trading license!). Traditionally, transactions were associated with database systems, but the semantics of transactions can be applied to any series of operations that involve making changes to data.

In a Web service environment, a transaction can span several services, possibly running on different computers within different organizations–this is a distributed transaction. In this environment, the underlying infrastructure must be able to guarantee consistency across a network and between potentially heterogeneous data stores. This is a complex task, bearing in mind the number of possible failure points in a network. This problem has been the subject of much research, and the commonly accepted standard mechanism for handling distributed transactions is the two-phase commit protocol. The OASIS organization has proposed the Web Services Atomic Transaction (WS-AtomicTransaction) specification describing a standard mechanism for handling transactions in a Web services infrastructure. The WS-AtomicTransaction specification defines the semantics of the two-phase commit protocol between Web services. Web services running on an infrastructure that conforms to the WS-AtomicTransaction specification should be interoperable with each other from a transactional perspective.

More Info 

For detailed information about the WS-AtomicTransaction specification, see the Web Services Atomic Transaction document on the Microsoft Web site at http://msdn.microsoft.com/library/en-us/dnglobspec/html/ws-atomictransaction.pdf.

The WS-AtomicTransaction specification is primarily useful when building Web services. However, WCF is not just concerned with Web services, and you can use it to build applications based on many other technologies, such as COM, MSMQ, and .NET Framework Remoting. Microsoft has provided their own transaction management features built into the current family of Microsoft Windows operating systems–Distributed Transaction Coordinator, or DTC, which uses its own optimized transaction protocol. Transactions based on the DTC transaction protocol are referred to as OLE transactions (OLE was the name of a technology that was the forerunner of COM). OLE transactions are ideal if you are building solutions based on Microsoft technologies.

The .NET Framework 3.0 provides a number of classes in the System.Transactions namespace. These classes provide an interface to the transaction management features of WCF, enabling you to develop code that is independent from the technology used to control the transactions that your code performs. In this chapter, you will see how to create a WCF service that supports transactions, and how to build client applications that can initiate and control them.




Microsoft Windows Communication Foundation Step by Step
Microsoft Windows Communication Foundation Step by Step (Step By Step Developer Series)
ISBN: 0735623368
EAN: 2147483647
Year: 2007
Pages: 105
Authors: John Sharp

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net