Two-Phase Commit (2PC) in Microservice Architecture 📌 Objective
This project demonstrates how to implement and simulate a distributed transaction using the Two-Phase Commit (2PC) protocol across three microservices:
Order Service (localhost:8081)
Payment Service (localhost:8082)
Coordinator Service (localhost:8080)
🏗️ Architecture Overview
-
Order Service
Manages order placement.
Exposes:
POST /prepare_order POST /commit_order POST /rollback_order -
Payment Service
Handles payment processing.
Exposes:
POST /prepare_payment POST /commit_payment POST /rollback_payment -
Coordinator Service
Orchestrates the 2PC protocol.
Steps:
Sends prepare to services. If all succeed, sends commit. If any fail, sends rollback