Where MSDTC needs to be installed in Distributed transaction case

≯℡__Kan透↙ 提交于 2019-12-20 03:38:07

问题


I need to maintain distributed transactions in my application

Assume Service1 is installed on Server1

[ServiceContract]
IService1
{
    [OperationContract]
    Operation1();
}

Service2 is installed on Server2

[ServiceContract]
IService2
{
    [OperationContract]
    Operation2();
}

and the client is consuming the two services

using (TransactionScope ts = new TransactionScope())
{
    Service1Proxy.Operation1();
    Service2Proxy.Operation2();
}

Where should i exactly install the MSDTC, do it required to be installed on Server1,Server2 and client

Is it requires any additional configuration in this case ?


回答1:


You would have to enable MSDTC on your clients and server 1, server 2.

you should allow outbound in the security configuration of MSDTC on your client.
you should allow Inbound and Outbound on your servers.
if your DB is on a seperate machine, it should allow Inbound.

One issue that I ran to using MSDTC, is don't forget to ALLOW MSDTC in the list of exception of your FIREWALL.

Looking at your code snippet, you'll need to add the Transactionflow attribut on your operation interface also.

Here is a good link for WCF with transactions : Foundation: Transaction Propagation




回答2:


I'd be careful about this setup. I've used "TransactionScope" to programmatically execute SQL commands that I want to run for testing purposes and then roll back, but I haven't tried to propogate "TransactionScope" through WCF calls.

A cursory Google search found this documentation on MSDN: http://msdn.microsoft.com/en-us/magazine/cc163432.aspx. This documentation says that you need special attributes on your Service interface to make your TransactionScope cross service boundaries.

As far as "installing" MSDTC, you do not install it. It should already be part of your Windows installation. However, MSDTC does not work with remote clients on the network by default; this setting is for security purposes. Here's a link showing how to enable MSDTC to work with remote clients in Windows Server 2003: http://support.microsoft.com/kb/817064. For other versions of Windows, try Googling for "MSDTC network access". I believe you'll need to set this configuration on each server hosting a service you want to include in a remote transaction.

WCF services can be very tricky to configure with all the different possible settings. I hope this helps you get started.



来源:https://stackoverflow.com/questions/2039966/where-msdtc-needs-to-be-installed-in-distributed-transaction-case

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!