Microservices Why Use RabbitMQ?

Elias picture Elias · Jul 20, 2017 · Viewed 19.2k times · Source

I haven't found an existing post asking this but apologize if I missed it.

I'm trying to get my head round microservices and have come across articles where RabbitMQ is used. I'm confused why RabbitMQ is needed. Is the intention that the services will use a web api to communicate with the outside world and RabbitMQ to communicate with each other?

Answer

Dimitar Tsonev picture Dimitar Tsonev · Jul 20, 2017

In Microservices architecture you have two ways to communicate between the microservices:

  • Synchronous - that is, each service calls directly the other microservice , which results in dependency between the services
  • Asynchronous - you have some central hub (or message queue) where you place all requests between the microservices and the corresponding service takes the request, process it and return the result to the caller. This is what RabbitMQ (or any other message queue - MSMQ and Apache Kafka are good alternatives) is used for. In this case all microservices know only about the existance of the hub.

microservices.io has some very nice articles about using microservices