I am trying to manipulate my objects received from Flux with data received from a Mono where the methods emitting the Flux of object and Mono of items are both different API calls. The problem is, I don't have control over the threads and the items received from the Mono are never assigned to my object unless I intentionally block() that thread. Kindly suggest if any non-blocking way possible for this scenario.
I have also looked into Schedulers, subscribeOn, publishOn but unable to figure out the pipeline.
public Flux<Object> test {
method1().map(obj -> {
if (obj.getTotalItems() > 20) {
obj.setItems(method2(obj).block());
}
return obj;
});
}
Here method1 is emitting Flux of objects received from API hit.
And method2 is emitting a list of items fetched from another API hit.
How can I make this whole flow non-blocking?