Distributed Transactions

ODP.NET, Managed and Unmanaged Drivers provide its resource manager, which manage Oracle database transactions, and work in cooperation with Microsoft Distributed Transaction Coordinator (MSDTC) to guarantee atomicity and isolation to an application across networks. MSDTC coordinates with all the resource managers that are enlisted to the same System.Transactions, to perform 2-phrase commit or rollback atomically. With that, Oracle distributed transactions can then be committed or rolled back across networks properly.

Oracle Services for Microsoft Transaction Server

Oracle Services for Microsoft Transaction (OraMTS) allow client components to leverage Oracle database participation in MSDTC transactions. It acts as a proxy for the Oracle database to MSDTC to ensure that Oracle distributed database transactions commit or rollback together with the rest of the distributed transaction.

If a failure occurs, such as a network failure or server hardware failure, then it can leave an in-process distributed transaction in-doubt. OraMTS has a recovery service to resolve these transactions on the machine that began this transaction. This recovery service runs as a Windows service.

It is required to install the OraMTS Recovery Service on all the client machines where ODP.NET is running and participating in MSDTC. As a machine may have multiple IP addresses, administrators for managed ODP.NET applications can specify the host machine name or IP address that has the running recovery service in the application's .NET configuration file. ODP.NET, Unmanaged Driver resolves the IP/machine name for the recovery service automatically.

With .NET Framework 4.5.2, Microsoft introduced new API support that allows Oracle to use only managed calls to coordinate ODP.NET transactions with the MSDTC. ODP.NET utilizes this managed code with the managed driver (starting with ODAC 12c Release 3) and with the unmanaged driver (starting with ODAC 12c Release 4).

While ODP.NET, Unmanaged Driver developers can opt out of using OraMTS when using the latest .NET Framework and ODP.NET versions, they still need to install and configure the OraMTS Windows recovery service to manage recovery scenarios.

Table 2-8 Supported ODP.NET Type and .NET Framework Version for Distributed Transaction

ODP.NET Type .NET Framework Version Distributed Transaction Support

Managed

4.5.2 and higher

Uses .NET Framework's native managed implementation (default) for distributed transactions. This is Oracle's recommended approach.

Managed

4.5.1 and lower

Uses the Oracle.ManagedDataAccessDTC.dll

Note:

Using managed ODP.NET distributed transactions with Oracle.ManagedDataAccessDTC.dll is deprecated as it is primarily used with .NET Framework 4 releases earlier than .NET 4.5.2. Microsoft has desupported these earlier .NET Framework 4 versions. Managed ODP.NET distributed transactions will continue to be supported and enhanced with .NET Framework's native fully managed distributed transaction implementation.

Unmanaged

4.5.2 and higher

Uses OraMTS (default) or managed OraMTS implementation. Oracle recommends using managed OraMTS for unmanaged ODP.NET applications requiring high availability from Oracle RAC or Data Guard.

Unmanaged

4.5.1 and lower

Uses OraMTS

Note:

While .NET Framework 4.5.1 and lower within the .NET Framework 4 family are no longer supported, administrators can still use any of the distributed transaction configurations listed above in conjunction with .NET 4.5.2 and higher. For .NET 4.5.1 and lower, the table merely recommends specific setups based on user configuration. They are not requirements.

See Also:

Manually Creating an Oracle MTS Recovery Service in Oracle Services for Microsoft Transaction Server Developer's Guide for Microsoft Windows.

ODP.NET, Managed Driver Setup

This section explains the setup and configuration steps required for using distributed transactions with ODP.NET, Managed Driver.

Oracle recommends that applications use .NET's native managed distributed transaction implementation (default), which is available in .NET Framework 4.5.2 or higher. Applications can set whether .NET's native managed distributed transaction or Oracle.ManagedDataAccessDTC.dll is used by setting the UseManagedDTC parameter in the .NET configuration file. Follow these steps to configure distributed transactions in these .NET Framework versions:

  1. Create and setup the OraMTS recovery service or make sure an existing recovery service is running.

  2. Set the value of OMTSRECO_PORT in the .NET configuration to specify the port number that the OraMTS recovery service is running.

Alternatively, you can still use Oracle.ManagedDataAccessDTC.dll with .NET Framework 4.5.2 and managed ODP.NET. To do so, set UseManagedDTC to true and follow the instructions listed below for .NET Framework 4.5.1.

For .NET Framework 4.5.1 and lower applications, follow these steps to setup and configure managed ODP.NET for distributed instructions:

  1. Create and setup the OraMTS recovery service or make sure an existing recovery service is running.

  2. Deploy Oracle.ManagedDataAccessDTC.dll along with the application.

  3. Set the value of OMTSRECO_PORT in the .NET configuration to specify the port number that the OraMTS recovery service is running.

Oracle.ManagedDataAccessDTC.dll is included with ODP.NET, Managed Driver. This DLL makes unmanaged MSDTC COM calls to MSDTC, which means there is a 32-bit version and 64-bit version of this DLL. These two DLLs share the same name. If you are using 32-bit .NET Framework, then deploy the 32-bit Oracle.ManagedDataAccessDTC.dll. If you are using 64-bit .NET Framework, then deploy the 64-bit Oracle.ManagedDataAccessDTC.dll. The DLLs are located in the following directories:

  • For 32-bit .NET Framework: ORACLE_HOME\odp.net\managed\x86

  • For 64-bit .NET Framework: ORACLE_HOME\odp.net\managed\x64

Upon ODP.NET installation, Oracle.ManagedDataAccessDTC.dll is no longer placed into the Global Assembly Cache (GAC). For applications that use this DLL, Oracle.ManagedDataAccessDTC.dll must either be placed in the application directory or in the GAC.

Oracle.ManagedDataAccessDTC.dll should not be directly referenced by a .NET application. It will be implicitly loaded by ODP.NET, Managed Driver when using distributed transactions.

For applications with platform target x64 or x86 specifically, Oracle.ManagedDataAccess.dll will load Oracle.ManagedDataAccessDTC.dll appropriately if it is placed into the GAC or if it resides in the application directory.

For applications that target AnyCPU, the corresponding Oracle.ManagedDataAccessDTC.dll needs to be placed into x64 and x86 subdirectories under wherever the Oracle.ManagedDataAccess.dll is loaded from by the application. ODP.NET, Managed Driver will load the appropriate Oracle.ManagedDataAccessDTC.dll assembly (32-bit or 64-bit), based on whether the application is 32-bit or 64-bit. If both 32-bit and 64-bit versions of Oracle.ManagedDataAccessDTC.dll are in the GAC, then the appropriate assemblies will be loaded automatically.

ODP.NET, Unmanaged Driver Setup

This section explains the setup and configuration steps required for using distributed transactions with ODP.NET, Unmanaged Driver.

For .NET Framework 4.5.2 and higher, ODP.NET, Unmanaged Driver has embedded a managed OraMTS implementation into its assembly. OraMTS remains the default implementation for the ODP.NET, Unmanaged Driver, but the managed OraMTS implementation is recommended when using any high availability FAN operations (HA Events = true) with Oracle Real Application Clusters or Oracle Data Guard. The managed OraMTS implementation supports this high availability functionality, while the traditional OraMTS does not.

Applications can set whether OraMTS (default) or managed OraMTS is used by setting the UseOraMTSManaged parameter in the .NET configuration file.

Install and configure OraMTS, including its recovery service to use OraMTS implementation for ODP.NET, Unmanaged Driver.

For .NET Framework 4.5.2 and higher applications, you can use the managed OraMTS implementation instead of the traditional OraMTS. To set this up, perform the following steps:

  1. Set UseOraMTSManaged to true in the .NET configuration file.

  2. Create and setup the OraMTS recovery service or make sure an existing recovery service is running.

See Also:

distributedTransaction section for more information about .NET configuration setup