We have a bunch of microservices written in different programming languages. These all communicate with each other over RabbitMQ(AMQP) middleware. There are consumers and publishers in each microservice which listen to incomming messages and publish on a RabbitMQ exchange respectively. The current architecture is shown in the image below
I want to decouple the Rabbit specific consumers and publishers from the microservices and implement them in a separate shared library as follows.
This shared library shall implement RabbitMQ exchange bindings. The consumer in this shared library, should listen to any incomming 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 problem I am facing is in making target language bindings with my shared library.
How should I share the functions of the target language that can be invoked by the shared library?
The reason for having a shared library is because, I can swap the current RabbitMQ message service with any other.
I request for some suggestions to approach this problem
EDIT
These microservices are written by a variety of teams spanning across different companies.
The reason for having a shared library
Since my current services directly implement RabbitMQ bindings, the integration test cases for each of the services also have a dependency on RabbitMQ.
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.