VertX 多个 Future 返回一个 Future
我正在尝试调用 3 个 future,等待它们完成,处理结果,然后将所有这些也作为 Future 返回。我似乎无法弄清楚如何将 3 个期货“包装”在未来中以使其返回,这样它就不会立即返回。我是 vertx 新手。
public Future<MyObject> getProjectStatus(int projectId) {
Future future = Future.future(ar -> {
MyObject object = new Myobject();
Future<x> f1 = callf1();
Future<y> f2 = callf2();
Future<z> f3 = callf3();
CompositeFuture cf = CompositeFuture.all(f1, f2, f3);
cf.onComplete(ar2 -> {
//Check Succeeds
if(ar2.succeeded()){
System.out.println("Completed!");
//DO FURTHER PROCESSING
} else {
System.out.println("Failure " + ar2.cause().getMessage());
}
}).map((object));
});
return future;
}
I am trying to call 3 futures, wait for them to complete, process the results and then return all of this also as a Future. I cant seem to figure out how to "wrap" the 3 futures in a future to be returned so that it doesnt just return immediately. I am new to vertx.
public Future<MyObject> getProjectStatus(int projectId) {
Future future = Future.future(ar -> {
MyObject object = new Myobject();
Future<x> f1 = callf1();
Future<y> f2 = callf2();
Future<z> f3 = callf3();
CompositeFuture cf = CompositeFuture.all(f1, f2, f3);
cf.onComplete(ar2 -> {
//Check Succeeds
if(ar2.succeeded()){
System.out.println("Completed!");
//DO FURTHER PROCESSING
} else {
System.out.println("Failure " + ar2.cause().getMessage());
}
}).map((object));
});
return future;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
或者
or