Hello,
Just starting with Vert.x so please bare with me.
In most of the examples in documentation database interaction is done on a verticle that also implements the http server.
In real life applications should we decouple the database interaction on a separate Verticle?
I was considering something like:
public class MainVerticle extends AbstractVerticle {
@Override
public void start() {
Vertx vertx = Vertx.vertx();
vertx.deployVerticle(new MongoDBClient(), this::ganericHandler);
vertx.deployVerticle(new HTTPServerVerticle(), this::ganericHandler);
}
private void ganericHandler(AsyncResult<String> ar) {
if (ar.succeeded()) {
System.out.println("Verticle deployment complete: "+ar.result());
} else {
System.out.println("Verticle deployment failed, Error:"+ar.cause());
}
}
}
Is this the Vert.x way? If so, how do I chain Verticles to make sure db is available before loading the server?
Thanks