代码之家  ›  专栏  ›  技术社区  ›  Francesco

以并行方式部署多个垂直

  •  0
  • Francesco  · 技术社区  · 7 年前

    我在学习 Vertx.io RxJava2 . 我想实现的是以一种并行的方式部署一些眩晕。这就是我要做的:

    ...
    public static void main(String[] args) {
      log = LoggerFactory.getLogger(TheMainApp.class);
      VertxOptions vertxOptions = new VertxOptions();
      Vertx vertx = Vertx.vertx(vertxOptions);
    
      try {
        JsonObject config = getPropertyFile(args);
        Flowable<Verticle> verticlesToDeploy = Flowable
            .fromArray(new Verticle[] { new Verticle1(), new Verticle2(), new Verticle3(), ..., new VerticleN() });
        verticlesToDeploy.flatMap(verticle -> {
        return RxHelper.deployVerticle(vertx, verticle, new DeploymentOptions().setConfig(config))
            .subscribeOn(Schedulers.io()).doOnError(err -> {
                log.error(err.getCause());
                throw new RuntimeException(err);
            }).doAfterSuccess(ok -> {
                log.info("Verticle {} deployed.", ok);
            }).toFlowable();
        });
      } catch (CompositeException | IOException e) {
        log.error("Deployment interrupted.");
        System.out.println(e.getMessage());
        vertx.close();
      }
    }
    ...
    

    但没用。没有垂直部署。我错过了什么?

    1 回复  |  直到 7 年前
        1
  •  0
  •   Kiskae    7 年前

    .flatMap 你不使用结果的可观察性。因为代码是在 main 可能需要添加的函数 .blockingSubscribe()