Both those calls are client http api:
Flux<SavingsViewFilter> views = savingsApi.getViewFilterSavings(viewId);
Flux<Group> groups = groupsApi.getAllGroups();
and return a Flux
requestBodySpec.retrieve().bodyToFlux(returnType);
I need to filter element inside the Flux<Group>
, based on values from eacg view.getGroupId()
return views.flatMap(view ->
groups
.filter(group -> Objects.equals(group.getGroupId(), view.getGroupId()))
.flatMap(group -> Flux.just(DepositAccount.builder()
.agencyName(group.getGroupName())
.settlementAccount(view.getName())
.build())));
It is working, but the problem is that it's doing for each view object, one more HTTP request to getAllGroups.
How can I avoid multiple requests to getAllGroups?