集群编程

如果您要以编程方式创建您的 Vert.x 实例,通过将 Vert.x 实例配置获得集群的event bus;

VertxOptions options = new VertxOptions();
Vertx.clusteredVertx(options, res -> {
  if (res.succeeded()) {
    Vertx vertx = res.result();
    EventBus eventBus = vertx.eventBus();
    System.out.println("We now have a clustered event bus: " + eventBus);
  } else {
    System.out.println("Failed: " + res.cause());
  }
});

你还应该确保你已经在你的类路径中实现ClusterManager,例如默认HazelcastClusterManager

Copyright © quanke.name 2016 all right reserved,powered by Gitbook该文件修订时间: 2016-09-06 03:18:18

results matching ""

    No results matching ""