transactionsmulemule-studiodistributed-transactionsxa

MuleSoft: XA Transaction management for two different REST Call


We have a situation where we need to manage db transaction across multiple rest api call.

In traditional example where new customer is registered, ordered, and payment done with different micro services.

We do have list of DB Micro REST Services and combination of SOAP and REST service which will used for business rule implementation.

Question is : how i am able to add transaction management wrapper around that so that it will rollback db data when only one getting failed.

I ready blogs of XA Transactions, but not able to get it how to use in my main project from where i am calling 1. 5 DB Micro Services 2. 1 External SOAP Service 3. 2 External REST Service.

Can someone help me out?

Thanks in Advance


Solution

  • Web technologies like SOAP en REST are not fit for participating in (XA) transactions. They are created for communication between independent systems that could potentially be located on the other side of the world. While it is technically possible to do it with SOAP (see for WS-Transaction on google) I would strongly advise against it because

    1. It is very difficult and error prone to get it to work correctly.
    2. Performance is really bad.
    3. Do you really trust an external service to start a transaction in yours? You have absolutely no control over how long the transaction will remain active, resulting in locks in your database that can quickly escalate to table locks, bringing your whole service down.

    You need a totally different architecture that involves saga's that orchestrate the calls to the different services and contain retry or compensation logic to cope with any of them failing. There are plenty of good articles on life without distributed transactions that explain these concepts. Far too complex to explain here.