Skip to content

Event Driven microservices with Spring Cloud Stream on RabbitMQ . Other Netflix libraries used here are- Zuul, Eureka, Feign, Sleuth

Notifications You must be signed in to change notification settings

roynilanjan/spring-cloud-stream-messaging

Repository files navigation

Building Event Driven microservices with Spring Cloud Stream and RabbitMQ

Introduction :

Spring Cloud Stream is a framework built on top of Spring Boot and Spring Integration framework, that helps in creating event-driven microservices at scale. In this application I introduce a simple order processing application using the capability of Spring Cloud Stream - following the event driven microservice architecture.

Overview of the application :

It consists of four independent microservices. gateway-service, order-service, customer-service and inventory-service

Communication between order-service and the customer-service happens through RabbitMQ broker over the orders-request and orders-reply channel .Since order-service is the source of the message , it sends messages to it's request channel. On the other hand, customer-service listens for incoming messages on the order-request channel and publishes the order status to the order-reply channel to which order-service listens to .This configuration has been provided in the application.yml of the order-service and the customer-service. The default topic exchange provide by spring cloud stream has been overidden with direct exchange to implement a point to point communication between order-service and customer-service .
Call to the Order-service from an external client comes through the API gateway .Order service receives the order and saves it in the repository and sends the order details message to the orders-request channel. customer-service receives the order from the orders-request channel , validates the customer id and calls the inventory-service over the rest endpoint to check the availability of the produts . If products are available and the customer has sufficient balance to place the order it sets the order to APPROVED else sets the status to REJECTED and send this order status to the orders-reply channel . Order-service receives the order status from the orders-reply channel and updates the status to the client when requested over an endpoint. Following diagram shows the architecture of the application.

order_processing

For the newbies to Spring Cloud stream , Spring Boot and AMQP :

Happy Messaging !

About

Event Driven microservices with Spring Cloud Stream on RabbitMQ . Other Netflix libraries used here are- Zuul, Eureka, Feign, Sleuth

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages