I'm new to Project Reactor in Spring, and I'm not fully sure how to perform something:
I have my pipeline the pipeline returns records. All good.
But I would like to count those records and then do something (like if else), where if records returned are > X then error, otherwise just continue.
Knowing that Count returns a Mono<Long>
, then I'll lose the records after that, what could I do?
I'm thinking:
Somehow use flatMap
and perform something inside this flatmap.
Somehow I see there is a reduce
method in Flux that might help.
The point is, I'm not sure how to proceed.
take
method to set a maximum number of elements emitted by the Flux, regardless of how many upstream elements are produced – Availabilitysubscribe
works baeldung.com/java-string-from-mono – Impost