NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Transactions

Developers targeting the NGWS runtime on Windows 2000 that want to use Component Services such as Transactions have a number of choices that are similar to what is provide today with Windows 2000 Component Services. The NGWS runtime provides Manual and Automatic Distributed transactions. Here is brief summary of the support that is detailed in this paper:

Manual Transactions

Today, developers can control Manual Transactions through BeginTransaction, CommitTransaction and AbortTransaction via the applicable Resource API, be that ADO, OLEDB, ODBC, MSMQ. They get explicit control over transaction. There is no co-ordination between data stores and no automatic enlistment in transactions across components. Transactions do not flow from user object to user object. This said, it is still a very valuable model and many customers want and need it. This programming model is also fully supported in the NGWS frameworks and runtime by:

Automatic Distributed Transactions

One of major advantages of the Automatic Distributed Transaction programming model (Windows 2000 Component Services) is that data stores (the Resource Managers) automatically enlisted in transactions. When the user is happy they just call SetComplete or and if unhappy call SetAbort. The transactions can span multiple databases. This automatic use of transactions is very popular and powerful

Today, Windows 2000 Component Services (and MTS on NT4) provides hosting of components. Some of the service configuration (such as transactions) for the Components can be specified on the component (for classic COM components in the TLB or in the NGWS Components using custom attributes). For example the transaction configuration could be Not Supported, Supported, Requires or RequiresNew.

The Component service configuration can be set through the Component Services MMC snapin Admin tool or via the related Admin APIs.

Whenever a request is made to instanciate one of these objects (via CoCreateInstance, the request is received by the COM (be that ComponentServices or MTS) it looks up the configuration for the component and depending on the settings (e.g. RequiresNew Transaction) creates a context, initiates a transaction with the DTC (Distributed Transaction Coordinator), and dispatches calls to this object. If the object accesses databases (or other resources managers that use transactions e.g. MSMQ), the transaction will be flowed to the database that will enlist in the transaction with DTC. The database drivers (ADO, ODBC, OLEDB) lookup the transaction in the Component Services Context. If the object tries to create new objects and these objects have transaction requirements, the transaction is flowed to the new context and these new objects. This programming model is also fully supported in the NGWS by:

Model

In this model transactions work with both NGWS Managed components and regular COM+ 1.0 components. Customers can build NGWS managed components that use transactions. Customer can also flow transactions between the managed and regular COM+ 1.0 components:

This allows customers to upgrade parts of their COM+ 1.0 application without upgrading everything i.e. leave some components in VB6 and move some components to VB7.

They can also write new NGWS components and these will participate in automatic distributed transactions. They can just mark their managed class with a custom attribute i.e. [TransactionAttribute(RequiresNew)] and be done. When it is time to create a new instance of the object a transaction is created. When a database operation was started the transaction would be flowed to the database, which would enlist in the transaction with DTC. NGWS components and classic COM components support the same model.