简体   繁体   中英

Vertx: Why is there no clustered verticle?

im messing around with my two verticles , which I want to start in clustered Mode.

Here are the start-Methods of my two verticles:

First Verticle:

public static void main(String[] args) {
    VertxOptions options = new VertxOptions();

    options.setClustered(true);
    options.setClusterManager(new HazelcastClusterManager());

    Vertx.clusteredVertx(options, res -> {
        Vertx vertx = res.result();
        vertx.deployVerticle(new WalzenSchnittBlMock());

    });

}

Second Verticle:

public void start() {
    VertxOptions options = new VertxOptions();

    Vertx.clusteredVertx(options, res -> {
        vertx = res.result();
        vertx.deployVerticle(serviceVerticle, this::completeRegister);
    });
}

Thhis two verticles reside on different machines, but they do not "see" each other, although there are in clustered mode....is there any problem..have i missed something?

I found the solution:

I have two machines and each of them have four networkcards - and vertx seems to choose the wrong one. So I am forced to set the Ip-adress which vertx should use. The result looks like that where the Ipadress is an argument of the jar-file :

VertxOptions options = new VertxOptions();

    Config config = new Config();
    NetworkConfig networkConfig = config.getNetworkConfig();

    networkConfig.getInterfaces().setEnabled(true).addInterface(args[0]);
    options.setClusterManager(new HazelcastClusterManager(config));
    options.setClustered(true);
    options.setClusterHost(args[0]);

    Vertx.clusteredVertx(options, res -> {
        Vertx vertx = res.result();
        vertx.deployVerticle(new Receiver());

    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM