Approach 2 - event-driven approach

In this approach, we use a message broker. NewCustomerService will create a new event and post it to the message broker. The following figure shows a high-level representation:

The three services--CustomerInformationService, MailService, and EmailService--will be listening on the message broker for new events. When they see the new customer event, they process it and execute the functionality of that specific service.

The key advantage of the event-driven approach is that there is no centralized magnet for all the business logic. Adding a new functionality is easier. We can create a new service to listen ...

Get Mastering Spring 5.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.