Transactions and the Order Processing Pipeline

A transaction is a series of operations performed as a single unit. In case of an error, the operations in a transaction can be undone. In the Active Server Pages (ASP) environment, transactions occur on a per-page level. To mark an ASP page as one that requires a transaction, you include the following script at the top of the ASP page:

<%@ LANGUAGE=VBScript Transaction=Required%>

When you mark an ASP page as transacted, the objects created on the page and the work those objects perform become part of the transaction, provided the objects are registered on the server as components supporting transactions. In the event of an error, the work performed by those objects can be rolled back.

Suppose, for example, that you create an ASP page that includes an object using Microsoft ActiveX Data Objects (ADO) to insert or update data in a database. In the event that this component fails, you can call the SetAbort method of the ObjectContext object to abort the transaction. This will undo all of the modifications made by the object to the database.

Ee810876.note(en-US,CS.20).gif Note

  • In Windows 2000, the transaction support provided by Microsoft Transaction Server (MTS) is now incorporated in COM+. The COM+ transaction support provides full backward compatibility with MTS. However, COM+ provides significant extensions to transactions. For more information, search for "More on Porting Applications from MTS to COM+" on the MSDN Web site.

Calling Transacted Pipeline Objects

The Commerce Server Order Processing pipeline (OPP) supports COM+ transactions through the MtsTxPipeline and PooledTxPipeline objects. These objects are marked as requiring a transaction. If you create an MtsTxPipeline object or a PooledTxPipeline object on an ASP page not marked as requiring a transaction, there is still a transaction, but the transaction includes only the pipeline and the components it runs. To extend the transaction to all operations on the page, the page must be marked as requiring a transaction.

In either case, the transaction support of the MtsTxPipeline object and the PooledTxPipeline object provides many benefits to the site developer. Most importantly, transaction support means that if any component in an MtsTxPipeline object or PooledTxPipeline object fails, the work of the preceding components in the pipeline is rolled back, and the pipeline object ends the transaction.

The transaction support of the MtsTxPipeline object and the PooledTxPipeline object is especially useful with pipeline components that modify the site database. If you use components that modify the site database, and a component following them fails, the modifications the components made to the site database are automatically rolled back. This is true whether or not the page is transacted because, as described above, the pipeline and the components it runs are always transacted.

For more information about the transacted pipeline objects, see MtsTxPipeline Object and PooledTxPipeline Object.

Copyright © 2005 Microsoft Corporation.
All rights reserved.