Demo project for Microservice Event-Driven Architecture
- Kotlin & Java
- Spring Boot Web
- Spring Cloud Stream Kafka
- Java - 1.11.x
- Gradle- 3.x.x
- Docker for kafka instance
Service Name | Port |
---|---|
Order Service | 8083 |
Courier Service | 8084 |
Email Service | 8085 |
Step 1: Running the Kafka & Zookeeper Open the project directory, Type the following command in your terminal to run kafka&zookeeper as a docker instances
docker-compose up -d
Step 2: Running the Order Service Open the this project path then order-service directory. Run the project with gradle:
./gradlew bootRun
Step 3: Running the Courier Service Open the this project path then courier-service directory. Run the project with gradle:
./gradlew bootRun
Step 4: Running the Courier Service Open the this project path then email-service directory. Run the project with gradle:
./gradlew bootRun
The app defines following for APIs.
POST http://localhost:8083/orders
{
"name": "Black Friday",
"productIds": [
14,
23,
34
],
"email": "[email protected]",
"userName": "G-khan",
"orderDetail": "%90 discount"
}
These examples present the order created event flow.
- Order Creates with API
- Order Service Creates Event as a OrderEvent with Created eventType
- Order Service produces orderEvent via kafka on orderEvent topic.
- Courier Service consumes the orderEvent and then assign the courier of order
- At the same time Email Service consumes the OrderEvent and then sends a fake email to user