Hands-On Microservices with Kubernetes
上QQ阅读APP看书,第一时间看更新

Using sagas to manage transactions across multiple services

The API composer and CQRS patterns provide adequate solutions for distributed queries when everything works well. However, maintaining distributed data integrity is a complex problem. If you store all your data in a single relational database and specify proper constraints in your schema, then you can rely on the database engine to take care of data integrity. The situation is very different with multiple microservices maintaining your data in isolated data stores (relational or non-relational). Data integrity is essential, but it must be maintained by your code. The saga pattern addresses this concern. Before diving into the saga pattern, let's understand data integrity in general.