2PC using MSDTC behaves differently on one/two computers
I have the following problem...
I start a transaction within one processproc1 (by creating a new TransactionScope) and enlist a custom IEnlistmentNotification implementation. Then, using .NET remoting, I call a method on a remote object (another processproc2) and pass the current Transaction to it. This method creates a new (nested) TransactionScope using the passed Transaction and enlists another custom IEnlistmentNotification implementation.
After completing bot scopes I can observe different behavior depending on whether the 2 processes run on a single computer or on two different computers.
(1) on one comp: The Prepare() method of theproc1 is called and in parallel Prepare() ofproc2 is called as well. (this is also my desired behavior)
(2) on two comps: Only Prepare() ofproc1 is called, but Prepare() ofproc2 is called only after the first one finishes.
Coresponding code:
PROC1:
using (scope = new TransactionScope() )
{
//Create an enlistment object
myEnlistmentClass1 myEnlistment = new myEnlistmentClass1();
//Enlist on the current transaction with the enlistment object
Transaction.Current.EnlistVolatile(myEnlistment, EnlistmentOptions.None);
//Perform transactional work here.
object remoteObj = Activator.GetObject(
typeof(RemoteProcess2),
"tcp://192.168.0.101:22223/RemoteProcess2.rem"); //change IP depending on home of proc2
RemoteProcess2 remoteProc2 = (RemoteProcess2)remoteObj;
remoteProc2.Execute(Transaction.Current);
scope.Complete();
}
PROC2:
public int Execute(Transaction txn)
{
using (TransactionScope scope = new TransactionScope(txn))
{
myEnlistmentClass2 myEnlistment = new myEnlistmentClass2();
Transaction.Current.EnlistVolatile(myEnlistment, EnlistmentOptions.None);
scope.Complete();
}
}
The classes myEnlistmentClass1 and 2 define a very simple implementations of the IEnlistmentNotification interfaces. The Prepare() method blocks for 10 seconds to better observe the described behavior using:
System.Threading.Thread.Sleep(10000);
Can anyone please explain this behavior? The two processes on one mashine define 2 app domains (or not?), so even in this case the MSDTC should got involved! Behaves the DTC differently in these cases?
thanks for any suggestions
Juraj

