Two Phase Commit
Why use two phase commit ? If need data consistency you use two phase commit. Additionally, it is briefly 2PC. If you wanna use microservices definitely know this.
Initially, I should mention a few terms.
When use to transaction process ? If we have sequential operations. A sample, like first update data then second add data or the exact opposite.
We use atomicity in ACID terms. What is atomicity ? Atomicity is during transactions, data in one or more tables are updated, and these transactions will either all succeed or all fail.
It has two stages. Those stages are preparation and commit.
We have a coordinator that is a managing service. The coordinator send a commit to nodes(subscribers). If any a node unable to make a promise, rollback is done.
If every node is okay, the coordinator carries out the necessary actions.
A sample for you.
Resources:
https://martinfowler.com/articles/patterns-of-distributed-systems/two-phase-commit.html