Junior — Middle
Can you list the main types of sagas in microservice architecture?
sobes.tech AI
Answer from AI
In microservices architecture, the main types of sagas can be divided into two approaches:
-
Choreography
- Each microservice independently performs its part of the transaction and publishes events that other services subscribe to.
- There is no central coordinator; control is distributed.
- Example: an order service publishes an "Order Created" event, and the payment service listens to this event to initiate payment.
-
Orchestration
- A central component (orchestrator) manages the execution of saga steps, calling microservices in sequence.
- The orchestrator controls the sequence and compensating actions in case of errors.
Both approaches help ensure data consistency in a distributed system without using distributed transactions.