1
votes

I've seen this on images multiple times, and just don't get it at all. Here is the javadoc:

https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Flux.html#flatMapSequentialDelayError-java.util.function.Function-int-int-

image in question(sorry, I'm unable to show it directly)

https://projectreactor.io/docs/core/release/api/reactor/core/publisher/doc-files/marbles/flatMapSequentialWithConcurrencyAndPrefetch.svg

Can someone explain, why is there 1 red square box? Why it's internal Flux was completed so soon? Based on what (in original flux) if purple is still emitted? What am I missing?

1

1 Answers

0
votes

The image is correct as far as I can tell.

What am I missing?

You seem to be assuming that the flatMapSequential() call is somehow affecting when the fluxes end, or when they emit their elements - the red flux ending after only one element and the others continuing for two. This isn't the case - this is just an example of what happens when you call flatMapSequential() on fluxes that just so happen to behave in this way.

If it helps, imagine they're 3 fluxes returning database records from a query. The green flux is subscribed to first, then it returns a result (but doesn't complete, because it's got another record to return still.) The red flux is then subscribed to, returns a result & completes (because there was only one record matching the query.) The Purple flux is then subscribed to, returns one result, then the green & purple fluxes return another result and then both complete.

In this case, if the red flux didn't complete, then the purple flux wouldn't be subscribed to until at least one of the green or red fluxes complete (since the max concurrency in this case its 2.) So picking fluxes that behave in this way for the example allows the image to be concise, as well as demonstrating both the "sequential" and the "max concurrency" elements visually.