I want to chain async rest service calls and have single callback when they finished.
Is it possible to do it with guava?
See Question&Answers more detail:osI want to chain async rest service calls and have single callback when they finished.
Is it possible to do it with guava?
See Question&Answers more detail:osFutures.chain
was removed in version 12.0
. The new method of chaining together ListenableFutures
is via the Futures.transform method.
https://github.com/google/guava/wiki/ListenableFutureExplained#application
From Guava latest javadoc (16.0.1
as of this writing).
ListenableFuture<RowKey> rowKeyFuture = indexService.lookUp(query);
AsyncFunction<RowKey, QueryResult> queryFunction =
new AsyncFunction<RowKey, QueryResult>() {
public ListenableFuture<QueryResult> apply(RowKey rowKey) {
return dataService.read(rowKey);
}
};
ListenableFuture<QueryResult> queryFuture = transform(rowKeyFuture, queryFunction);