From Vert.x docs :
Vert.x calls this method when un-deploying the instance. You do not call it yourself.
If you start Vert.x from the main method and terminate the JVM process (for example, by clicking the stop button in Eclipse), Vert.x probably does not signal a vertical abandonment or the JVM terminates before Vert.x manages to expand the vertices .
You can do several things to ensure that the vertical will not be expanded, and will call the stop () method:
- Launch Verticle using the vertx command line. When you stop the process (or return vert.x to stop), Vert.x will make sure that all vertices are not expanded.
You can programmatically expand expanded vertices by retrieving the deployId list and calling undeploy for all id:
vertx.deploymentIDs().forEach(vertx::undeploy);
You can programmatically stop Vert.x:
vertx.close();
You can add a shutdown crane to make sure that one of the above options is executed when the JVM completes:
Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { vertx.close(); } });
You can either programmatically expand the index by calling the Vert.x API, or simply stop the Java process, which at the end starts the Vert.x process to stop.
By the way, you should ask yourself if it really is necessary that the stop () method is always called when the process that starts the vertical stops. You can never be sure that this will happen; when a process is forcibly stopped or killed, the stop () method may not be called.
source share