Search code examples
.nettransactionscopeservicebusmasstransit

does MassTransit support distributed transactions?


I have read Udi's article Life without distributed transactions.

Does MassTransit support distributed transactions? (to avoid duplication problem on the MassTransit, not manually checking by code)


Solution

  • MassTransit has a feature called Courier, which implements distributed transactions using an execute/compensate style routing slip approach. You can see a code sample on GitHub: https://github.com/MassTransit/Sample-Booking

    The routing slip breaks a transaction into a set of activities that are performed atomically, in order, with compensation information logged in the routing slip. If an activity faults, the previously completed activities are compensated so that partial transactions are not left open.

    This is the basis for doing distributed transactions, and has been used in several large scale distributed transaction processing applications in production today.

    Another good example of Courier usage: https://github.com/phatboyg/Demo-Registration