Question

Using WCF and the Microsoft Distributed Transaction Co-ordinator, is it possible to implement a long-running transaction against a single database? I've drawn out a simplified version of the scenario in question.

Is there a time limit that transactions have to occur within?

Assuming the DB is SQL Server or Oracle, would there be locking that would occur during the transaction? Would it be at the row level or table level?

enter image description here

Was it helpful?

Solution

Database transactions should be short-lived. See for instance Are long-living transactions acceptable?

So, while WCF and DTC will allow you to distribute the transactions across Machines and through SOAP calls, this is not a good idea for the scenario you are describing.

Use compensating transaction logic instead, e.g. remove the inserted Emp1 and Emp2 when the creation of Emp3 fails. Or manually mark the inserted Emp1 and Emp2 rows as still-in-transaction until they've all been successfully written. Or collect the actions in the WCF Service and then (transactionally) commit them to the Database when all information has become available.

Which solution is best depends on the details of your use case.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top