Nishant123
Nishant123

Reputation: 1966

How to decouple messaging middleware from microservices?

We have a bunch of microservices written in different programming languages by a variety of teams spanning across different companies. All these services communicate with each other over RabbitMQ(AMQP) middleware. There are consumers and publishers in each microservice which listen to incoming messages and publish on a RabbitMQ exchange respectively. The current architecture is shown in the image below

enter image description here

I want to decouple the RabbitMQ specific consumers and publishers from the microservices and implement them in a separate shared library as follows.

enter image description here

This shared library shall implement RabbitMQ exchange bindings. The consumer in this shared library, should listen to any incoming messages and invoke the relevant method in the target language. Same for publishers, the target language should be able to invoke a method in the shared library responsible to publish message on RabbitMQ.

The reason I want to have a shared library is

  1. Since my current services directly implement RabbitMQ bindings, the integration test cases for each of the services also have a dependency on RabbitMQ.
  2. I can easily swap RabbitMQ for any other messaging service(for example Kafka) without changing my services, as this makes the services oblivious of the underlining messaging service.

The problem that I am currently facing is creating language bindings.

If I decide to write the shared library in Java, since most of the message queuing services have good support for Java, how to achieve language bindings?

I am still planning this and haven't started with the implementation. Please provide some suggestions on approaching this problem.

Upvotes: 0

Views: 188

Answers (1)

jmhostalet
jmhostalet

Reputation: 4649

you are not actually decopling them, you are moving the coupling to a lib in a difficult way, not easy to maintain. Try to follow KISS principle

Upvotes: 1

Related Questions