What is the exact usage of prefetch in Flux.concatMap? As in documentation, it is "the inner source produced demand". But if my inner sources produce more than prefetch value, they are emitted by concatMap.
What is the exact usage of prefetch in Flux.concatMap? As in documentation, it is "the inner source produced demand". But if my inner sources produce more than prefetch value, they are emitted by concatMap.
The description of the parameter in the Javadoc isn't the clearest. A better description IMHO would be:
The number of elements requested from the inner source / publisher for its first request.
Prefetching is essentially an optimisation in reactor to try to ensure the downstream operators always have enough capacity to keep them busy. Instead of requesting elements one by one, reactor requests a number of items upfront (the prefetch value, default 32), and then requests 75% of this value when 75% is exhausted on an ongoing basis.
This is covered in the reactor documentation on backpressure, which is worth a read if you haven't already.