Chapter 15: Handling Eventual Consistency with the Compensation Pattern
We will now turn our attention to how microservices communicate with each other and how we handle transactions when each microservice is invoked in the context of its own transaction. We will learn how to handle that issue using eventual consistency, and as a byproduct, we will also see how we can reduce the coupling between our services. We will then learn how to handle errors and do what under commitment control would have been a rollback, by using the compensation pattern. Then, we will learn how to implement what we have learned and how to set up Google Cloud Pub/Sub to support that implementation. Finally, we will deploy and test our updated application.
In this chapter, we will cover the following topics:
- The distributed transaction problem
- The compensation pattern
- Creating topics and subscriptions with Google Cloud Pub/Sub
- Implementing eventual consistency and the compensation pattern...