There's this concept of back-pressure on project reactor, which is transparent from developers. Want to understand how it really works.
Let's use the following code block
fun consumeMethod(data: Flux<String>) {
data
.flatMap { slowHttpCall(it) }
.subscribe()
}
Is my understanding correct regarding the flow of execution:
- When we call subscribe(), it will request the publisher to send ALL of the data.
- Moving up to the flatMap, let's say it will request 32 elements to the publisher.
- The publisher then will send 32 elements
- Moving down to flatMap again, it will call slowHttpCall() for 32 elements without waiting until each http call to complete. So right now we have 32 ongoing http calls
- Let's stop here
At this point, will flatMap request more element from the publisher? Or will it wait until all 32 http calls to complete before requesting for more? Or will it wait until 1 complete and request 1? How much will it request and why?
Thank you