This is a simple sample that illustrates how to use Vert.x EventBus with reply:
-
eventbus-receiver listens to messages. Depending on the address, it can reply with a timeout for a while or a failure before replying with a sucess message.
-
eventbus-sender starts verticles that sends a "Hello" message. If the reply is timeout or has a failure, attempts to retry to send the message several times
There is a version with Handler
and with RxJava
.
The sample uses a Vert.x cluster of the above described verticles.
mvn clean install
cd eventbus-receiver
mvn clean vertx:run -Dvertx.runArgs="-cluster" -Dvertx.jvmArguments="-Djava.util.logging.config.file=logging.properties"
Open another terminal:
cd eventbus-sender
mvn clean vertx:run -Dvertx.runArgs="-cluster" -Dvertx.jvmArguments="-Djava.util.logging.config.file=logging.properties"
Create a Run
configuration for the project
eventbus-receiver
with
the following configuration:
-
Main class:
io.vertx.core.Launcher
-
VM options:
-Djava.util.logging.config.file=src/main/resources/logging.properties
-
Program arguments:
run org.ws13.howtos.vertx.eventbus.receiver.DeployVerticle -cluster
-
Use of classpath module:
eventbus-receiver
The VM option switch off the verbosity of the Cluster library Ignite
Create a Run
configuration for the project
eventbus-sender
with
the following configuration:
-
Main class:
io.vertx.core.Launcher
-
VM options:
-Djava.util.logging.config.file=src/main/resources/logging.properties
-
Program arguments:
run org.ws13.howtos.vertx.eventbus.sender.DeployVerticle -cluster
-
Use of classpath module:
eventbus-sender
The VM option switch off the verbosity of the Cluster library Ignite
Run the eventbus-receiver
first since it listens to messages sent by
the eventbus-sender
at startup.