Search code examples
dockerarchitecturerabbitmqmicroservicesmessagebroker

Microservice architecture with API Gateway talking to Message Broker instead of directly to Microservices


One of the main concerns when implementing an API Gateway is that you are coupling that tier with the internal microservices. Is there such an architecture having the API Gateway only communicate directly to a message broker like Rabbit MQ which then talks to the microservices based on the message?

In most architecture guides that I see the message broker is used for microservice to microservice communication only. Why not make it be used for API Gateway and microservice to microservice communication?


Solution

  • Usually, the way an API Gateway communicates with the internal microservices is more of a implementation detail. Nothing prevents you to use a message broker to realize that.

    The main drawback of de-coupling the API Gateway with the actual microservices is that it complicates a bit the synchronous handling of API calls. What you usually end up implementing is some sort of long polling mechanism.

    Therefore, it just depends on your use case. If I am dealing with asynchronous APIs then I usually rely on message brokers for de-coupling the front-end with the back-end.