简体   繁体   中英

Access deployment id of vertx verticle from outside the inner class?

Hi i have deployed vertx verticle like this and now i want the asynchResult access this inner class. I have gone through many posts but didnt find any solution for that.

container.deployVerticle("com.demo.vertx.FirstVert", snmp_trap_listener_count, new AsyncResultHandler<String>() {
                public void handle(AsyncResult<String> asyncResult) {
                    if (asyncResult.succeeded()) {
                        System.out.println("The verticle has been deployed, deployment ID is " + asyncResult.result());
                    } else {
                        asyncResult.cause().printStackTrace();
                    }
                }
                });

Please help to resolve this ..

You can get the deployment ID as a result from the asynchronous handler like this:

container.deployVerticle("foo.ChildVerticle", new AsyncResultHandler<String>() {
public void handle(AsyncResult<String> asyncResult) {
    if (asyncResult.succeeded()) {
        System.out.println("The verticle has been deployed, deployment ID is " + asyncResult.result());
    } else {
        asyncResult.cause().printStackTrace();
    }
}

});

If you undeploy a verticle all of his children will be undeployed as well. Undeploying a verticle works like this:

container.undeployVerticle(deploymentID);

So guy's i got my answer . I have just made a setId local method which takes AsynchResult as parameter and from inside inner class passed asynchResult to this method. So i got values in this method.

private void setDeployIds(AsyncResult<String> asyncResult){
          System.out.println("Deployment ID :" +asynchResult.result());
      }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM