Event bus Microservices

Bernardo Teixeira
3 min readMay 3, 2020

I will write a series of articles about microservices so be tune!

What is an Event bus?

Imagine this, you have one microservice for Users and other for Transactions. Each time a user create one transaction the microservice Transactions need to know what kind of transaction is and user. So the Gateway microservice will send an event and the microservice Transaction will listen to the event. And take care of the new transaction made.

The Event bus will be responsible for publishing the event and delivering the event to the correct microservice (the simple way to understand).

With Event bus you can make your communication asynchronous and also you lose coupling between microservices. Because, if you use HTTP for communicating between microservices you will make the user be waiting for each microservice. Will be like a waterfall, for the microservice to start, the previous microservice needs to end and so on. Not very efficient.

Message Broker

But for this, we need a message broker. I will use RabbitMQ, the correct way to this will be like, service A publish an event using Event bus, the Event bus will publish the event in some queue in the RabbitMQ, next the Event bus will be listening to the RabbitMQ and will subscribe and will deliver the event to the…

--

--