Here is an example of how the SAGA pattern could be used in an e-commerce order fulfillment process to handle a rollback scenario:
The customer places an order on the e-commerce website and provides their payment information.
The website’s order fulfillment microservice begins a local transaction and sends a request to the inventory microservice, asking it to reserve the items in the customer’s order.
The inventory microservice begins a local transaction and reserves the items in the customer’s order.
The inventory microservice sends a response back to the order fulfillment microservice, indicating that the items were reserved successfully.
The order fulfillment microservice receives the response from the inventory microservice and, assuming everything went as planned, it charges the customer’s payment method and commits its own local transaction.