Skip to content

G-khan/async-communication-between-microservices

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Asynchronous Microservice Communication Example with Event-Driven Architecture

Demo project for Microservice Event-Driven Architecture

  • Kotlin & Java
  • Spring Boot Web
  • Spring Cloud Stream Kafka

Image for post

Requirements

  1. Java - 1.11.x
  2. Gradle- 3.x.x
  3. 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

Rest APIs

The app defines following for APIs.

POST http://localhost:8083/orders

{
    "name": "Black Friday",
    "productIds": [
        14,
        23,
        34
    ],
    "email": "gokhana@mail.com",
    "userName": "G-khan",
    "orderDetail": "%90 discount"
}

Example

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

About

Async communication between microservices

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published