Implementing eventual consistency and the compensation pattern
In this section, we examine the code required to implement eventual consistency and compensations. Before jumping into our code, we will briefly discuss Spring Integration, which gives us a standardized way of handling enterprise integration patterns in our code, much as Spring Data gives us a standardized way of handling object-relational mapping and transactional databases. We do not need to get down to the low-level detail of the Google Pub/Sub application programming interface (API) as that is abstracted for us by Spring Integration. The major components of Spring Integration we will need to understand are listed here:
ChannelAdapter
: A channel adapter is an interface provided by Spring that handles the low-level details of communicating with a provider. In our case, Spring Integration provides aPubSubInboundChannelAdapter
component, which implements this interface to handle Google Cloud Pub/Sub and receives...