Integration with Distributed Transaction Coordinator

Meta Data Services Programming

Meta Data Services Programming

Integration with Distributed Transaction Coordinator

You can design an application that runs a distributed transaction on Microsoft® SQL Server™ 2000 running on Microsoft Windows® 2000.

Before you use Microsoft Distributed Transaction Coordinator (MS DTC) with a SQL Server 2000 Meta Data Services repository, you must install the Windows 2000 Service Pack 1. This service pack fixes an intermittent bug that causes MS DTC to stop responding when committing changes to a repository database.

The protocol for coordinating transaction atomicity across multiple resource managers is a two-phase commit. The Microsoft facility for a two-phase commit is MS DTC. You can enable distributed transactions to support the following scenarios:

  • Create an application that updates data in two repositories within the same transaction.

  • Create an application that updates data in a repository and in another database within the same transaction.

  • Create an application that runs a Microsoft Transaction Server (MTS) to update a repository, while running the application within the transaction that called it.

  • Create an information model that aggregates a repository object class and updates another database within the aggregation wrapper.

The distributed transaction must be atomic; that is, it must either commit at all resource managers or terminate at all of them. For more information about supporting atomic operations, see Transaction Management Overview.

The Transaction Protocol

To support MS DTC in your application, you must set the TXN_USE_DTC transaction flag. IRepositoryTransaction supports the TXN_USE_DTC flag on the GetOption and SetOption methods. The bit value for TXN_USE_DTC is 10. The default value of this option is FALSE. If the value is set to TRUE, each call to IRepositoryTransaction::Begin will create an MS DTC transaction.

IRepositoryTransaction::SetOption(10, 1)
IRepositoryTransaction::Begin

MS DTC requires that the participant who started the transaction be the only party who can call Commit.

Programming in Visual C++

If you are a Microsoft Visual C++® programmer, you can use the ITransactionJoin::JoinTransaction method. You can use this method to cause a repository instance that is not currently running a transaction to become part of an existing MS DTC transaction. The active MS DTC transaction object is passed in as an input argument. For more information about the ITransactionJoin interface, see SQL Server Books Online.

Programming in Microsoft Visual Basic

Microsoft Visual Basic® applications must use the following API to enlist an MS DTC transaction:

HRESULT IRepositoryTransaction2::JoinTransaction ([in]VARIANT sVArTxn);

where sVArTxn is an IUnknown pointer to the distributed transaction coordinator.

See Also

IRepositoryTransaction::begin

IRepositoryTransaction::commit

IRepositoryTransaction::getOption

IRepositoryTransaction::setOption

Managing Transactions and Threads