Search code examples
javamicroservicesvert.x

What is the best way to communicate between microservices in vertx, by web client or some middleware?


I have not done much in vert.x microservices, but I ran into the doubt of knowing the best way to communicate with each other miscroservices vert.x, using some middleware or web client, I do not know, or any other way that vert.x allows me.


Solution

  • There's an infinite of possibilities to allow vert.x microservices to communicate between them, each with pros and cons and with more or less relevance depending on the context.

    Here is 3 common ways :

    1) Using the native vert.x eventBus ( asynchronous logic) : https://vertx.io/docs/vertx-core/java/#event_bus (and you can use the Hazelcast Cluster Manager using the -cluster option when you need to handle communication between different JVM pids : https://vertx.io/docs/vertx-hazelcast/java/ ).

    2) Using a messages broker system like Apache Kafka ( sometimes you need persistent message queues with replay mechanisms, which I think is more powerful than the vert.x's event bus, sometimes you need to communicate with multiple languages written microservices and the vert.x event bus is not relevant to do that) or an old fashion JMS compliant system like ActiveMQ, RabbitMQ & cie.

    3) Sometimes it's more relevant to expose simple Restful api, so you can use the vertx-web extension to do that : https://vertx.io/docs/vertx-web/java/