.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Melody Anderson

Home >> Articles >> .Net Framework >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Using Automatic Transactions

Posted By:Shashi Ray       Posted Date: November 30, 2009    Points: 25    Category: .Net Framework    URL: http://www.dotnetspark.com  


Using Automatic Transactions

Automatic transactions simplify the programming model because they do not require that you explicitly begin a new transaction or explicitly commit or abort the transaction. However, the most significant advantage of automatic transactions is that they work in conjunction with the DTC, which allows a single transaction to span multiple distributed data sources. In a large-scale distributed application, this advantage can be significant. Although it is possible to manually control distributed transactions by programming the DTC directly, automated transactions drastically simplify the task and are designed for component-based systems. For example, it is easy to declaratively configure multiple components to perform work that comprises a single transaction.

Automatic transactions rely on the distributed transaction support features provided by COM+, and as a result, only serviced components (that is, components that are derived from the ServicedComponent class) can use automatic transactions.

To configure a class for automatic transactions:

  • Derive the class from the ServicedComponent class located within the System.EnterpriseServices namespace.
  • Define the transaction requirements of the class by using the Transaction attribute. The value supplied from the TransactionOption enumerated type determines how the class will be configured in the COM+ catalog. Other properties that can be established with this attribute include the transaction isolation level and time-out.
  • To avoid explicitly having to vote in the transaction outcome, you can annotate methods with the AutoComplete attribute. If these methods throw an exception, the transaction will be aborted automatically. Note that you can still directly vote toward transaction outcome if required.

More Information

  • For more information about COM+ automatic transactions, search for "Automatic Transactions Through COM+" within the Platform SDK documentation.

Configuring Transaction Isolation Levels

The transaction isolation level for COM+ version 1.0-that is, COM+ running on Windows 2000-is Serialized. Although this offers the highest degree of isolation, such protection comes at the cost of performance. The overall throughput of your system is reduced because the resource managers (typically databases) involved must hold both read and write locks for the duration of the transaction. During this time, all other transactions are blocked, which can have a significant impact on your application's ability to scale.

COM+ version 1.5, which ships with Microsoft Windows .NET, allows the transaction isolation level to be configured in the COM+ catalog on a per component basis. The setting associated with the root component in the transaction determines the isolation level for the transaction. In addition, internal subcomponents that are part of the same transaction stream must not have a transaction level higher than that defined by the root component. If they do, an error will result when the subcomponent is instantiated.

For .NET managed classes, the Transaction attribute supports the public Isolation property. You can use this property to declaratively specify a particular isolation level, as illustrated in the following code.

 [Transaction(TransactionOption.Supported, Isolation=TransactionIsolationLevel.ReadCommitted)]
public class Account : ServicedComponent
  . . .



Shashi Ray

 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend