I am unable to retrieve value out of the Future object. Below is the code for reference
Future<Configure> conf = getLatestVersion(request);
Configure cc = conf.result();
float previousVersion = cc.getVersionNo();
Here is the implmentation of the getLatestVersion(request)
public Future<Configure> getLatestVersion(Configure request) {
Future<Configure> result = Future.future();
configRepository.getLatestVersionNo(request).setHandler(res -> {
if (res.succeeded()) {
result.complete(res.result());
System.out.println("==result from db =="+res.result());
System.out.println("== getVersionNo ="+res.result().getVersionNo());
} else {
result.fail(res.cause());
}
});
return result;
}
In the SOPs i am able get the values from the result.result()
and the result.result().getVersion()
, but after returning the result from this method to the above caller i am not able to fetch the values.
What i want to achieve here is i need the Configure
pojo data out from the Future<Configure>
.
You should be using onComplete()
callback (or setHandler()
in earlier versions):
Future<Configure> conf = getLatestVersion(request);
conf.onComplete( res -> {
if( res.succeded() ){
Configure cc = res.result();
float previousVersion = cc.getVersionNo();
}
} );