25 Star 60 Fork 21

ServiceComb / ServiceComb-Saga

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 2.02 KB
一键复制 编辑 原始数据 按行查看 历史

Booking Demo

This demo simulates a booking application including three services:

  • booking
  • car
  • hotel

Prerequisites

You will need:

  1. JDK 1.8
  2. Maven 3.x
  3. Docker
  4. Docker compose
  5. alpha server

Running Demo

You can run the demo using either docker compose or executable files.

via docker compose

  1. run the following command to create docker images in saga project root folder.
    mvn clean package -DskipTests -Pdocker -Pdemo
  2. Enter the saga servicecomb demo directory and give permissions to script
    cd ./saga-demo/saga-servicecomb-demo
    chmod +x saga-servicecomb-demo.sh
  3. start the whole application up(including alpha server and three demo services)
    ./saga-servicecomb-demo.sh up
  4. stop application
    ./saga-servicecomb-demo.sh down

User Requests by command line tools

  1. 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
  1. 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

Debugging

Take the spring-demo debugging as a reference.

Java
1
https://gitee.com/servicecomb/ServiceComb-Saga.git
git@gitee.com:servicecomb/ServiceComb-Saga.git
servicecomb
ServiceComb-Saga
ServiceComb-Saga
master

搜索帮助