我正在使用vertx3。我嘗試過版本3.0.0 - 3.1.0 - 3.2.0 - SNAPSHOT,並在所有這些發生。Vertx3 - EventBus不能在集羣中工作
爲了簡化問題,我創建了2個簡單的Verticle。第一個作爲消息的消費者,第二個通過事件總線發送消息。
問題是,事件總線看起來不工作,我在集羣中運行時有超時。
我不明白爲什麼作爲看起來像第二個節點加入羣集等
我這裏添加的代碼。
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?");
});
});
}
}
我運行的是verticles與
java -jar counter-service-1.0-SNAPSHOT-fat.jar -cluster -cluster-host 192.168.112.9
和seecond一個具有:
java -jar test-service-1.0-SNAPSHOT-fat.jar -cluster -cluster-host 192.168.112.10
我在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>
以下cluster.xml這cluster.xml在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>
當我運行的第一verticle,我有
Members [2] {
Member [192.168.112.9]:5701 this
Member [192.168.112.10]:5701
}
,並從第二個節點
Members [2] {
Member [192.168.112.9]:5701
Member [192.168.112.10]:5701 this
}
但我只能從第二個節點,其具有的第二個之後
sending message test
and 10 seconds後
Message reply handler timed out as no reply was received - it will be removed
error?
在不同的機器上運行時發生這種情況,但是當在同一臺機器上運行時,一切正常。 他們在CentOS中運行,禁用防火牆,內部IP之間的通信很好......所以有些想法?
感謝,