List<Object> someList = getSomeList();
someList.stream().forEach( (callSomeCompletableFutureFunction)
.thenCompose ( call another completableFutureFunction)
.whenComplete(response, exception) -> {
if (Objects.nonNull(response)) {
// do something
someCode
} else {
// log or throw error
someCode
}
} ); // everything is in forEach loop
What is if I directly call forEach on list ? How will it impact on completableFuture which is getting processed inside the callSomeFuntion ? What is the difference between stream and foreach in this case [suppose you are sending SMS in Async manner after collecting data in sequence of thenCompose call] ?