跨应用程序域和进程的TransactionScope应用程序、进程、TransactionScope

由网友(回忆说、让我忘了你)分享简介:这是真的使用System.Transactions的(主要的TransactionScope)在不同的应用程序域和进程?Is it real to use System.Transactions (primarily TransactionScope) across different AppDomains and...

这是真的使用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.

更新

我们不使用 DependentClone 。我们使用 GetTransactionFromTransmitterPropagationToken 通过交易作为字节数组。非常相似的第二示例传播在整个应用程序域的交易。

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();
    }
}
阅读全文

相关推荐

最新文章