Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Use Future<Void> instead of timers
package com.github.vertx.node.example;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Vertx;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
public class MainVerticle extends AbstractVerticle {
private final Logger logger = LoggerFactory.getLogger(MainVerticle.class);
public void start(Future<Void> future) {
/** Count of services. */
final AtomicInteger serviceCount = new AtomicInteger();
/** List of verticles that we are starting. */
final List<AbstractVerticle> verticles = Arrays.asList(new HelloWorldVerticle(), new WebVerticle());
verticles.forEach(verticle -> vertx.deployVerticle(verticle, deployResponse -> {
if (deployResponse.failed()) {
Throwable cause = deployResponse.cause();
logger.error("Unable to deploy verticle " + verticle.getClass().getSimpleName(), cause);;
} else { + " deployed");
if (serviceCount.incrementAndGet() == verticles.size()) {
public static void main(final String... args) {
final Vertx vertx = Vertx.vertx();
vertx.deployVerticle(new MainVerticle());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.