2017-05-09 52 views
0

我主要verticle不同的端口上部署其他verticles:Vert.x中不同端口上的多个Verticle部署集群环境。问题

public void start(Future<Void> startFuture) throws Exception { 

    ... 

    final DeploymentOptions frontOptions = new DeploymentOptions() 
      .setInstances(Configuration.HZ_NB_INSTANCES_NOTIFICATION); 

    final DeploymentOptions backOptions = new DeploymentOptions() 
      .setInstances(Configuration.HZ_NB_INSTANCES_NOTIFICATION); 


    ... 

    ClusterManager mgr = new HazelcastClusterManager(); 
    VertxOptions options = new VertxOptions().setClusterManager(mgr); 

    Vertx.clusteredVertx(options, res -> { 
     if (res.succeeded()) { 

    vertx.deployVerticle(WebVerticle.class.getName(), frontOptions, 
     deployResult -> { 
        if (deployResult.succeeded()) {           
         vertx.deployVerticle(SockVerticle.class.getName(), 
        backOptions , deployResult1 -> { 

        ... 
     } 
     } 
    } 
    } 

凡WebVerticle用于创建一个Vert.x Web Server,这将主办8090的所有静态文件(HttpServer的)。

而SockVerticle用于创建关于8091使用SockJSHandler(HttpServer的)一个EventBus。

有时当我们加载应用程序时,它无法处理eventbus上收到的消息,所以我必须在chrome中进行硬刷新。

我应该创建暴露的HttpServer(8090)的网页(静态网页)两种不同的fat.jar和暴露的HttpServer(8091)(后端操作)eventbus?

回答

0

我要更新我的Java参数聚类:

运行com.xxx.MainVerticle --launcher级= io.vertx.core.Launcher --conf = xxx.json -Dvertx.options .blockedThreadCheckInterval = 200000000 -Dfile.encoding = UTF-8 -cp。 -cluster