This demo simulates a booking application including three services:
- booking
- car
- hotel
You will need:
You can run the demo using either docker compose or executable files.
- run the following command to create docker images in saga project root folder.
mvn clean package -DskipTests -Pdocker -Pdemo
- Enter the saga servicecomb demo directory and give permissions to script
cd ./saga-demo/saga-servicecomb-demo chmod +x saga-servicecomb-demo.sh
- start the whole application up(including alpha server and three demo services)
./saga-servicecomb-demo.sh up
- stop application
./saga-servicecomb-demo.sh down
- Booking 2 rooms and 2 cars, this booking will be OK.
curl -X POST http://${host_address}:8083/booking/test/2/2
Check the hotel booking status with
curl http://${host_address}:8081/bookings
Check the car booking status with
curl http://${host_address}:8082/bookings
- Booking 3 rooms and 2 cars, this booking will cause the hotel order failed and trigger the compensate operation with car booking.
curl -X POST http://${host_address}:8083/booking/test/3/2
Check the hotel booking status with
curl http://${host_address}:8081/bookings
Check the car booking status with
curl http://${host_address}:8082/bookings
The second car booking will be marked with cancel:true
Take the spring-demo debugging as a reference.