问题描述
这是真的使用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();
}
}
这篇关于跨应用程序域和进程的TransactionScope的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!