Approach 2 –  The 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 diagram shows a high-level representation of this:

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 will 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 business logic. Adding new functionality is easier. We can create a new service to listen for the event on the message broker. Another important thing to note is that we don't need to make changes to any of the existing services.

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

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