hdimitrieski / e-shop

Sample Spring Cloud microservices e-shop.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Q]What does the design of distributed transactions ?

blling opened this issue · comments

AxonFramework use saga to manage distributed transactions, but this project does not use saga, so what does the design of distributed transactions?

@blling Actually, Some form of the saga pattern is used for the distributed transactions in this project but without any external tool or library.
The order processing service acts as an orchestrator for the order checkout process. The order processing service creates an order, saves it in the database, and starts a new distributed transaction. It communicates with the catalog service to check if all items are available, and it communicates with the payment service that makes the actual payment. When the payment is accepted, the order processing service receives the confirmation and communicates with the catalog service to update the stock. The order processing service keeps track of the transaction by maintaining the status of the order. Also, in case the payment is not accepted or some items are not in stock, it publishes compensating events to cancel the order.
It would be better to use something like Seata or Conductor to implement distributed transactions.

Axonframework natively supports saga, why not use Axonframework Saga

@blling Axon is used only in catalog-query and catalog-command so it cannot be used for the transactions that span other services.