分布式事务案例中需要安装MSDTC的地方

发布于 2024-08-17 18:50:56 字数 532 浏览 3 评论 0原文

我需要在我的应用程序中维护分布式事务

假设Service1安装在Server1上

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

Service2安装在Server2上

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

并且客户端正在使用这两个服务

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

我应该在哪里准确安装MSDTC,是否需要安装在 Server1,Server2和客户端

在这种情况下是否需要任何额外的配置?

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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

走走停停 2024-08-24 18:50:56

您必须在客户端和服务器 1、服务器 2 上启用 MSDTC。

您应该在客户端上的 MSDTC 安全配置中允许出站。
您应该在您的服务器上允许入站和出站。
如果您的数据库位于一台单独的计算机上,则它应该允许入站。

我在使用 MSDTC 时遇到的一个问题是,不要忘记在防火墙的例外列表中允许 MSDTC。

查看您的代码片段,您还需要在操作界面上添加 Transactionflow 属性。

以下是 WCF 与事务的良好链接:基础:事务传播

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

川水往事 2024-08-24 18:50:56

我会小心这个设置。我已经使用“TransactionScope”以编程方式执行 SQL 命令,我想运行这些命令以进行测试,然后回滚,但我没有尝试通过 WCF 调用传播“TransactionScope”。

粗略的 Google 搜索在 MSDN 上找到了此文档:http://msdn.microsoft。 com/en-us/magazine/cc163432.aspx。本文档指出,您的 Service 接口上需要特殊属性,以使 TransactionScope 跨服务边界。

至于“安装”MSDTC,您并没有安装它。它应该已经是您的 Windows 安装的一部分。但是,默认情况下,MSDTC 不与网络上的远程客户端一起工作;此设置是出于安全目的。下面的链接显示了如何启用 MSDTC 来与 Windows Server 2003 中的远程客户端配合使用:http://support。 microsoft.com/kb/817064。对于其他版本的 Windows,请尝试在 Google 上搜索“MSDTC 网络访问”。我相信您需要在托管要包含在远程事务中的服务的每台服务器上设置此配置。

使用所有不同的可能设置来配置 WCF 服务可能非常棘手。我希望这可以帮助您入门。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文