Reputation: 657
I am using vertx3. I tried with version 3.0.0 - 3.1.0 - 3.2.0-SNAPSHOT and in all of them is happening.
For simplify the problem I created 2 simple Verticles. The first one act as a consumer of a message and the second one send a message through the event bus.
The problem is that the eventBus looks not working and I am having timeouts when runs in a cluster.
I can't understand why as looks like that the second node joins the cluster, etc.
I add here the code.
public class FirstVerticle extends AbstractVerticle {
private final Logger log = LoggerFactory.getLogger(getClass());
@Override
public void start() {
getVertx().eventBus().consumer("test-service", message -> {
log.info(String.format("test-Service receive: %s", message));
message.reply("ok");
}).completionHandler(event -> {
if(event.succeeded()) log.info("complete handler");
else log.info("failed");
});
log.info("Done initializing");
}
}
public class SecondVerticle extends AbstractVerticle {
private final Logger log = LoggerFactory.getLogger(getClass());
@Override
public void start() {
log.info("Done initializing test");
getVertx().setPeriodic(2000L, id -> {
log.info("sending message test");
getVertx().eventBus().send("test-service", "hi", response -> {
if(response.succeeded()) log.info("success");
else log.info("error?");
});
});
}
}
I am running the verticles with
java -jar counter-service-1.0-SNAPSHOT-fat.jar -cluster -cluster-host 192.168.112.9
and the seecond one with:
java -jar test-service-1.0-SNAPSHOT-fat.jar -cluster -cluster-host 192.168.112.10
I have the following cluster.xml in the FirstVerticle
<network>
<port auto-increment="true" port-count="10000">5701</port>
<outbound-ports>
<ports>0</ports>
</outbound-ports>
<join>
<multicast enabled="false">
<multicast-group>224.2.2.3</multicast-group>
<multicast-port>54327</multicast-port>
</multicast>
<tcp-ip enabled="true" connection-timeout-seconds="10">
<interface>192.168.112.9</interface>
<interface>192.168.112.10</interface>
</tcp-ip>
</join>
<interfaces enabled="true">
<interface>192.168.112.*</interface>
</interfaces>
</network>
and this cluster.xml in the SecondVerticle
<network>
<port auto-increment="true" port-count="10000">5701</port>
<outbound-ports>
<ports>0</ports>
</outbound-ports>
<join>
<multicast enabled="false">
<multicast-group>224.2.2.3</multicast-group>
<multicast-port>54327</multicast-port>
</multicast>
<tcp-ip enabled="true" connection-timeout-seconds="10" >
<interface>192.168.112.9</interface>
<interface>192.168.112.10</interface>
</tcp-ip>
</join>
<interfaces enabled="true">
<interface>192.168.112.*</interface>
</interfaces>
</network>
When I run the first verticle and after the second one I am having
Members [2] {
Member [192.168.112.9]:5701 this
Member [192.168.112.10]:5701
}
and from the second node
Members [2] {
Member [192.168.112.9]:5701
Member [192.168.112.10]:5701 this
}
But I am only having from the second node
sending message test
and after 10 seconds
Message reply handler timed out as no reply was received - it will be removed
error?
This is happening when is running in different machines, but when is running in the same machine everything is working fine. They are running in CentOS, firewall disabled, communication between internal IPs are fine.... so some idea ?
Thanks,
Upvotes: 3
Views: 3241
Reputation: 657
Finally I managed to make it works with different configurations, using tcp-ip and multicast.
Basically the main problems is because of the blocking by the firewall or because multicast is not enabled.
Also one of the problems I had is when the server has more than one network interface, so has to be specify which one use in the cluster.xml
I've created a github repository with 3 different configurations that finally are working fine in cluster hope it helps.
https://github.com/mustaine/vertx3-ping-pong
Upvotes: 6