-
I am using elastic search async client which is able to return Whith sync clilent I can do : return Multi.createFrom().emitter(emitter -> {
var hasNext = true;
List<String> searchAfterList = new ArrayList<>();
while (hasNext){
var result = getPaginateItems(dataSourceId, sort, searchAfterList);
hasNext = !result.isEmpty();
if (hasNext) {
emitter.emit(result);
searchAfterList.clear();
searchAfterList.addAll(result.getSearchAfterList());
} else {
emitter.complete();
}
}
}); But this is blocking. How can I achieve the same with |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
The emitter doesn't have to be a in loop, and it can outlive the lifespan of the lambda / callback. I'd suggest you use one of the |
Beta Was this translation helpful? Give feedback.
The emitter doesn't have to be a in loop, and it can outlive the lifespan of the lambda / callback.
I'd suggest you use one of the
CompletableFuture
method to be notified when it completes, then push elements usingemitter
, then callgetPaginateItems
again.