跨AppDomains和进程的TransactionScope [英] TransactionScope across AppDomains and processes

查看:340
本文介绍了跨AppDomains和进程的TransactionScope的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否真的在不同的AppDomain和进程之间使用System.Transactions(主要是TransactionScope)?

Is it real to use System.Transactions (primarily TransactionScope) across different AppDomains and processes?

DependentTransaction 仅在一个AppDomain中有效。

DependentTransaction works only inside one AppDomain.

推荐答案

是的,它的工作原理。我们通过WCF传递事务,调出过程事务COM +组件,并手动将事务从.NET 2.0 asmx Web服务传递到WCF服务。

Yes, it works. We are flowing transactions via WCF, calling out of process transactional COM+ components, and manually passing transactions from a .NET 2.0 asmx web service to a WCF service.

现在这不是说设置不够精细。我想大多数问题都是在所有服务器上正确设置MSDTC。

Now that is not to say that the setup is not finicky. I think most of the issues were around getting MSDTC set up properly on all the servers.

UPDATE

我们不使用 DependentClone 。我们使用 GetTransactionFromTransmitterPropagationToken 以字节数组的形式传递事务。非常类似于在AppDomains之间传播事务

We don't use DependentClone. We are passing the transaction as a byte array using GetTransactionFromTransmitterPropagationToken. Very similar to the second example of Propagating a Transaction Across AppDomains.

例如:

public void CallOutOfProcessAndPassTransaction
{
    Client client = new Client();

    client.DoSomethingTransactional(
        System.Transactions.TransactionInterop.GetTransmitterPropagationToken(
            System.Transactions.Transaction.Current)
    );
}

服务:

public void DoSomethingTransactional(byte[] tx)
{
    using (TransactionScope ts = new TransactionScope(
               TransactionInterop.GetTransactionFromTransmitterPropagationToken(tx)))
    {
        // Do Something

        // vote to commit the transaction if the caller also agrees
        ts.Complete();
    }
}

这篇关于跨AppDomains和进程的TransactionScope的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆