Git Product home page Git Product logo

async-communication-between-microservices's Introduction

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": "[email protected]",
    "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

async-communication-between-microservices's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.