Skip to content

Latest commit

 

History

History

spring-reactive-services

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Spring WebFlux Reactive Services

Simple example of a reactive services using Spring WebFlux and R2DBC.

Services

How to Run

Start databases.

dodker compose up -d

Start user-service application.

cd user-service
./gradlew bootRun

Start order-service application.

cd order-service
./gradlew bootRun

Testing

Create a user.

curl -X POST http://localhost:8080/users \
  -H "Content-Type: application/json" \
  -d '{"name": "Mike"}' | jq .

{
  "id": 1,
  "name": "Mike"
}

Create orders for the user.

curl -X POST http://localhost:8081/orders \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Order1",
    "userId": 1
  }' | jq .

{
  "id": 1,
  "name": "Order1",
  "userId": 1
}

curl -X POST http://localhost:8081/orders \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Order2",
    "userId": 1
  }' | jq .

{
  "id": 2,
  "name": "Order2",
  "userId": 1
}

Get the user with orders.
User service calls order service to get corresponding orders.

curl http://localhost:8080/users/1/orders | jq .

[
  {
    "id": 1,
    "name": "Mike",
    "orders": [
      {
        "id": 1,
        "name": "Order1"
      },
      {
        "id": 2,
        "name": "Order2"
      }
    ]
  }
]