How can I deploy a bunch of verticles and wait for all of them to start successfully? And what should I do if one or more verticles fail to deploy?
This is what I have so far:
private void deployVerticles(Stack<String> verticles, Future<Void> future) {
vertx.deployVerticle(verticles.pop(), v -> {
if (v.succeeded()) {
if (verticles.empty()) {
future.complete();
}
else {
deployVerticles(verticles, future);
}
}
else {
future.fail("Unable to deploy all verticles");
}
});
}
Stack<String> verticles = new Stack<String>();
verticles.push("js:Verticle1.js");
verticles.push("js:Verticle2.js");
verticles.push("js:Verticle3.js");
Future<Void> future = Future.future();
future.setHandler(r -> {
// Proceed with whatever
});
deployVerticles(verticles, future);
I'm not sure how to implement this in a clean way. The example code above doesn't seem to be a good way to achieve this.
Your help much appreciated!