Deploying verticles in order

To finalize the MainVerticle refactoring, we must make sure the deployment operations get triggered and happen in order:

  1. dbVerticleDeployment
  2. .flatMap(id -> { (1)
  3. Single<String> httpVerticleDeployment = vertx.rxDeployVerticle(
  4. "io.vertx.guides.wiki.http.HttpServerVerticle",
  5. new DeploymentOptions().setInstances(2));
  6. return httpVerticleDeployment;
  7. })
  8. .flatMap(id -> vertx.rxDeployVerticle("io.vertx.guides.wiki.http.AuthInitializerVerticle")) (2)
  9. .subscribe(id -> promise.complete(), promise::fail); (3)
  1. The flatMap operator applies the function to the result of dbVerticleDeployment. Here it schedules the deployment of the HttpServerVerticle.

  2. We use the shorter lambda form here.

  3. Operations start when subscribing. On success or on error, the MainVerticle start future is either completed or failed.