This is shown in the following code:
public Future<Boolean> sendHeartbeat(List<BrokerMeta> brokerMetas) {
PromiseInternal<Boolean> resultPromise = ContextInternal.current().promise();
for (BrokerMeta brokerMeta : brokerMetas) {
if (null == brokerMeta.getAdr()) {
continue;
}
remote(brokerMeta.getAdr());
}
return resultPromise.future();
}
private Future<String> remote(String addr) {
PromiseInternal<String> promise = ContextInternal.current().promise();
// Request remote....
promise.complete("From remote");
return promise.future();
}
I want the Remote methods to execute one by one and return, and then I'm pushing resultPromise down,How do I write this code?