Deploying a Verticle

Create Vertx Instance

Here is how you create a Vertx instance:

import io.vertx.core.Vertx;

public class VertxApp {
    public static void main(String[] args) {
        Vertx vertx = Vertx.vertx();
    }
}

You create a Vertx instance by calling Vertx.vertx().

Creating a Verticle

Before you can deploy a verticle you need to create it. You do so by creating a class that extends AbstractVerticle. Here is a verticle example:

package com.example.starter;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Future;
import io.vertx.core.Promise;

public class MyVerticle  extends AbstractVerticle {
  @Override
  public void start(Promise<Void> startPromise) {
    System.out.println("MyVerticle started!");
  }

  @Override
  public void stop(Promise<Void> startPromise) throws Exception {
    System.out.println("MyVerticle stopped!");
  }
}

A verticle has a start() and a stop() method which are called when the verticle is deployed and when it is undeployed. You should perform any necessary initialization work inside the start() method, and any necessary cleanup work inside the stop() method.

Deploying a Verticle

Once you have created a verticle you need to deploy it to the Vertx instance. You deploy a verticle using one of the deployVerticle() methods on the Vertx instance. Here is a Vert.x verticle deployment example:

package com.example.starter;

import io.vertx.core.Vertx;

public class VertxVerticleMain {

  public static void main(String[] args) {
    Vertx vertx = Vertx.vertx();
    vertx.deployVerticle(new MyVerticle());
  }
}

The verticle is deployed using this method call:

vertx.deployVerticle(new MyVerticle());

Complete Code: http://jreact.com/index.php/2023/12/07/deploying-a-verticle/