Building an event-driven Reactive Asynchronous System

Let's build a sample project that demonstrates how to create a real-time streaming application using event-driven architecture, Spring Cloud Stream, Spring Boot, Apache Kafka, and Spring Netflix Eureka. Let's see the application architecture:

We have used Netflix Hystrix to implement the circuit breaker pattern, we will discuss it in Chapter 10Building Resilient Systems Using Hystrix and Turbine. We also configured the API Gateway proxy using Netflix Zuul, as we have already discussed in Chapter 7, Creating API Gateway with Netflix Zuul Proxy.

In previous chapters, we have discussed using microservices architectures to decouple large and complex systems into simple independent micoservices. In this chapter, we are discussing the Event-driven microservices architecture, it is a methodology used to produce, handle events, and implement applications where events transmit among decoupled software components and services.

We are going to create an application with microservices, such as Account, Customer, and Notification. Whenever we create a customer record or create an account for a customer, a notification service sends an email and a mobile notification.

We have three decoupled services—Account, Customer, and Notification. All of them are independently deployable applications. And also we have the edge service for API Gateway using Netflix Zuul. The Account service can be used to create, read, update, delete customer accounts. The Account service sends a message to the Kafka topic when a new account is created.

Similarly, the Customer service is used to create, read, update, delete a customer in the database. The Customer service sends a message to the Kafka topic when a new customer is created. And the Notification service sends email and SMS notifications. The Notification service listens on topics from incoming customer and account messages and then processes these messages by sending notifications to the given email and mobile.

The Account and Customer microservices have their own H2 database, and Notification service uses MongoDB. In this application, we will use the Spring Cloud Stream module to provide abstract messaging mechanisms in the application; it is a framework for building event-driven microservice applications.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.107.229