Search code examples
wcfdistributed-transactionstransactionscope

WCF Distributed Transactions at several servers and one Database


There are two servers are running some services on WCF. All services are working with a shared database. All services use transport net.tcp with allowed transaction flows

Problem appeared after we start use TransactionScope: The first method successfully creates the user second successfully gets his profile

but the third method fails with error user not found in database

using(TransactionScope scope = new TransactionScope())
{
   long employeeId = serviceOnServerA.CreateEmployee(profile);
   var employeeProfile = serviceOnServerA.GetEmployeeProfile(employeeId );

   serviceOnServerB.CreateContract(employeeId);    
   scope.Complete();
}

but such scenario:

using(TransactionScope scope = new TransactionScope())
{
   long employeeId = serviceOnServerA.CreateEmployee(work1);
   var employeeProfile = serviceOnServerA.GetEmployeeProfile(employeeId );
   scope.Complete();
}
serviceOnServerB.CreateContract(employeeId);

Work fine, but not suitable for my task;

The problem is seen that the local transaction created on the server A is not visible on server B. Somebody known how to solve this problem;


Solution

  • The problem solved. Problem related with used npgsql database provider, which not supported DTC. Code rewrited to MSSQL - and problem gone.