Booking service changes

You can perform the following steps to implement the booking order distributed transaction using sagas:

  1. First, we'll add the saga-lib dependency in the pom.xml file of booking-service as follows:
<dependency>  <groupId>com.codebullets.saga-lib</groupId>  <artifactId>saga-lib</artifactId>  <version>3.2.0</version></dependency>

This provides basic saga features, such as distributed saga start/stop and the compensating transaction calls required for the implementation of sagas .

  1. Next, we'll add the input cloud, stream, and binding to application.yml to receive the billing response, as shown in bold:
spring:  cloud:    stream:      bindings:        bookingOrderOutput:          destination: amp.bookingOrdered          contentType: application/*+avro billingInput: ...

Get Mastering Microservices with Java - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.