I have to write a function that returns CompletionStage<Void>.
This function can query paginated data(async operation, returns data wrapped in CompletionStage) and process them and query the next set of data until it finishes processing the entire set of data.
Is there a way I can use a while loop with the completion stage without using join?
public CompletionStage<Void> process(Input){
while(allDataProcessed){
queryDataAndProcess(This itself is async function)
}
}
The drawback of this solution is that it might create many object in memory. To avoid this issues you could use the IBM async utils:
With Maven, you can add it to your project with:
This library implements the Trampoline pattern