Skip to content

Saga Orchestrator Pattern

Satish Kumbhar edited this page Feb 20, 2024 · 4 revisions

API Journeys (Orchestration Pattern)

1) Place a order with wallet payment mode

  • The Order microservice receives a request to create an order. It creates an order with the status "Initiated" and publishes an "OrderInitiated" event.
  • The Orchestrator microservice listens for the "OrderInitiated" event. Upon receiving the event, it routes that call to payment ms.
  • Payment ms then attempts to process the payment by calling HTTP call to the Wallet microservice. If the payment is successful, it publishes a "PaymentSucceeded" event. If the payment fails, it publishes a "PaymentFailed" event with a reason.
  • The Payment MS communicates with the Wallet MS to check if the wallet has enough balance. If so, it subtracts the required amount and confirms the payment.
  • Payment MS then publishes an event to Kafka, which listend by orchestrator ms and o. ms performs event to order ms with latest order status. And then calls Inventory MS with order details.

2) Insufficient fund flow for wallet payment mode (Insufficient fund while placing order) -

  • Wallet MS throws error to payment MS with insufficent fund
  • Payment MS will trigger event to kafa and order MS will receive event with insufficent flow
  • Payment MS will create event to orchestrator ms.
  • Orchestrator ms will ask order ms(async or api call ?) to update order status and orchestrator ms will call notification service that wallet have not fund.

Rough page =

  1. When payment MS found that there is insufficient fund in wallet, then what should we do ? (This is grace condition, as mostly from user experience we will do wallet ms check user placing order) => Orchestrator MS should tell order ms that order is failed with the appropriate reason, and call notification service to send notification to user regarding order failed.
  2. When inventory MS found that inventory is insufficient or product is not present ? -> Orchestrator MS should refund amount. Update order MS and notify user with notification MS that insufficient inventory.