Distributed configuration of transactionscope

Source: Internet
Author: User

Transactionscope is a good thing. It can automatically manage transaction, even for distributed databases, but it takes two days to configure it ...), The environment in this article is Windows 2003:

 

1. Configure component services on the machine where the code is run and the server where the SQL is located

Administative tools-> component services-> open component services-> computers-> my computer-> right-click Properties-> select MSDTC-> Security Configuration-> follow the following configurations-> OK-> restart the Distributed Transaction Coordinator Service (you must manually restart the service)

 

The most important are Allow inbound and allow outbound. other meanings are as follows:

 

 

Setting

Description

Corresponding registry value

Network DTC Access

Determines whether DTC on the local computer is allowed to access the network. This setting must be enabled in combination with one of the other settings to enable Network DTC transactions.

Default setting: Off

Security/networkdtcaccess

0 = off

1 = on

Allow inbound

Allows a distributed transaction that originates from a remote computer to run on this computer.

Default setting: Off

To enable this setting you must set the following registry key values to 1:

Security/networkdtcaccess

Security/networkdtcaccesstransactions

Security/networkdtcaccessinbound

To disable this setting, you only need to set the following registry key value to 0:

Security/networkdtcaccessinbound

Allow outbound

Allows the local computer to initiate a transaction and run it on a remote computer.

To enable this setting, you need to set the following registry key values to 1:

Security/networkdtcaccess

Security/networkdtcaccesstransactions

Security/networkdtcaccessoutbound

To disable this setting, you only need to set the following registry key value to 0:

Security/networkdtcaccessoutbound

Mutual authentication required

Adds support for mutual authentication in future versions and is the highest secured communication mode. This is the recommended transaction mode for clients running Windows XP SP2 and servers running one of the Windows Server 2003 operating systems.

Allowonlysecurerpccils = 1

Fallbacktounsecurerpcifnecessary = 0

Turnoffrpcsecurity = 0

Incoming caller authentication required

Requires the local DTC to communicate with a remote DTC using only encrypted messages and mutual authentication. This setting is recommended for servers running Windows Server 2003 that are operating in a cluster.

Only Windows Server 2003 and Windows XP SP2 support this feature, so you shoshould only use this if you know that the DTC on the remote computer runs either the Windows Server 2003 or Windows XP SP2 operating system.

Allowonlysecurerpccils = 0

Fallbacktounsecurerpcifnecessary = 1

Turnoffrpcsecurity = 0

No Authentication Required

Provides system compatibility between previous versions of the Windows operating system. when enabled, communication on the network between dtcs can fall back to a non-authentication or non-encrypted communication if a secure communication channel cannot be established. this setting shoshould be used if the DTC on the remote computer runs a Windows 2000 operating system or a Windows XP operating system earlier than SP2. this setting is also useful when the dtcs that are involved are located on computers that are in domains that do not have an established trust relationship or if the computers are part of a Windows workgroup.

Allowonlysecurerpccils = 0

Fallbacktounsecurerpcifnecessary = 0

Turnoffrpcsecurity = 1

 

 

 

2. configure the firewall, and configure the machine where the code is run and the server where the SQL is located.

 

Windows Firewall-> exceptions-> Add Program-> browse-> "C:/Windows/system32/msdtc.exe"-> OK

Msdtc.exe is a Windows distributed service program.

 

 

A solution on the blog is as follows:

 

Step 1:
--------------------
To disable remote/network transactions by default in win2003, follow these steps:
To enable Network DTC Access
1. Click Start, point to control panel, and click Add/delete programs ".
2. Click "Add/delete Windows Components ".
3. Select "Application Server" and click "details ".
4. Select enable Network DTC Access and click OK ".
5. Click "Next ".
6. Click Finish ".
7. Stop the Distributed Transaction Coordinator service and restart it.
8. Stop any resource manager services (such as Microsoft SQL Server or Microsoft Message Queue Server) involved in distributed transactions and restart them.
--------------------------------
Step 2:
--------------------------------
Set MSDTC: Control Panel-> Administrative Tools-> component services-> my computer-> right-click-> properties-> MSDTC-> Security Configuration) -> enable Network DTC Access and
Allow inbound, Allow outbound, no authentication required, enable transaction Internet Protocol [tip] transaction
---------------------------------
Step 3: add the MSDTC program to the Windows Firewall

Note: The two machines involved in distributed transactions must be configured as above. If the problem persists, restart the machine.

The first step is more than me, and the first step is not used in my experiment.

Some people say that transactionscope does not support cross-origin access. In my experiment, cross-origin is supported.

 

Transactionscope needs to be supplemented in the following aspects:

1. connection must be enabled and closed within transactionscope

2. If an exception occurs during SQL Execution, it will be thrown to transactionscope to let transactionscope know that an exception has occurred. Prepare to roll back.

Distributed configuration of transactionscope

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.