I have a Vert.x 3.7.1 method that deploys a bunch of verticles and if all of the deployments succeed, sends a message through the event bus that does some startup work. The structure of the method looks like this:
void deploy() {
Future<Void> v1Future = Future.future();
Future<Void> v2Future = Future.future();
// ...
vertx.deployVerticle(new SomeVerticle(), result -> {
if (result.succeeded()) {
v1Future.complete();
} else {
v1Future.fail(result.cause());
}
});
// ...
List<Future<Void>> allFutures = ImmutableList.of(v1Future, v2Future);
CompositeFuture.all(allFutures).setHandler(result -> {
if (result.succeeded()) {
vertx.eventBus().send("some-address");
}
});
}
I want to replicate this same functionality with Promise
s in Vert.x 3.8.1+, since Future.future()
and most of the associated methods are now deprecated. The problem is, there's no CompositePromise
or anything that seems similar to Future
s. How can I execute a series of deployments and then if and only if all deployments succeed, do something else using the new Promise
class in Vert.x 3.8.1+?
vertx.deployVerticle(new SomeVerticle(), v1Promise)
? It would be nice for fluency – Waldo