Hi,
I want to deploy a verticle with service which lasts long, until I stop the jar with zookeeper as backend
I use the basic vertx to deploy the verticle.
// Verticle Snippet MyVerticl.java
ServiceDiscovery discovery = ServiceDiscovery.create(vertx,
new ServiceDiscoveryOptions().setBackendConfiguration(new JsonObject()
.put("connection", "localhost:2181")
.put("ephemeral", true)
.put("guaranteed", true)
.put("basePath", "/service/my-services")));
Record record = HttpEndpoint.createRecord("myhttpClient", "localhost", "8000", "/");
discovery.publish(record, ar -> {
if (ar.succeeded() && null != ar.result()) {
this.recordId = ar.result().getRegistration();
fut.complete();
} else {
fut.fail("Unable to start service");
}
});
discovery.close();
In the main I deploy my verticle as below
public static void main(String... args) {
Vertx vertx = Vertx.vertx();
vertx.deployVerticle(new MyVerticle(), new DeploymentOptions(), ar -> {
if (ar.succeeded) {
// Succeeded codes
}
else {
// Failure Handler
}
});
}
But this cause the service to stop abruptly when the main snippet vertx stops, I am running on a single threaded event loop. I don't have clusters so I cannot setHa in Deployment option to pass the verticle to other vertx.
What would be the ideal way to deploy a standalone service verticle?