0

I'm new to Vert.x and I'm a little bit confused with how to run\deploy Vert.x app.

I'm used to write a server by having a main class with static main() method which there performs all my initial startup code, like: connecting to DB, reading configuration files, initializing internal services and eventually creating the listening socket for accepting new connections.

For example:

public class Server {

   public static void main(String args[]) {
      Server server = new Server();

      server.run();
   }

   public void run() {
     // load configuration
      ....

    // Connect to DB
    ....

    // Initialize internal services
    ....

    // Create listening socket on server port
    ...

   // and more...
}

now to my question:

Vert.x forces me to make my main class extends Verticle class and override start() method to initialize the listening socket.

so now all my initialization process must be done inside this start() method.

Does this make sense??

and I can never run my application via command line like I'm used to but rather use the "vertex" app

Am I missing something??

Shvalb
  • 1,835
  • 2
  • 30
  • 60

1 Answers1

0

Yes, you are correct. A vertx app is nothing but a set of verticles running inside vertx instances.

If you want your app to have main method as usual then you can use vertx as embedded mode i.e inside your main method you start a vertx instance using the API and then start verticles inside that instance.

Check out embedding guide at: https://vertx.io/vertx2/embedding_manual.html

asam
  • 359
  • 3
  • 12
Ankur
  • 33,367
  • 2
  • 46
  • 72