I've read from the documentation that flatMap
:
Transform the elements emitted by this Flux asynchronously into Publishers, then flatten these inner publishers into a single Flux through merging, which allow them to interleave.
that flatMapSequential
:
Transform the elements emitted by this Flux asynchronously into Publishers, then flatten these inner publishers into a single Flux, but merge them in the order of their source element.
and that concatMap
:
Transform the elements emitted by this Flux asynchronously into Publishers, then flatten these inner publishers into a single Flux, sequentially and preserving order using concatenation. There are three dimensions to this operator that can be compared with flatMap and flatMapSequential:
Generation of inners and subscription: this operator waits for one inner to complete before generating the next one and subscribing to it.
Ordering of the flattened values: this operator naturally preserves the same order as the source elements, concatenating the inners from each source element sequentially.
Interleaving: this operator does not let values from different inners interleave (concatenation).
The difference between flatMap
and the other two is pretty understandable, but I don't understand when the difference between concatMap
and flatMapSequential
takes place. Is there any performance difference between the two? I've read that flatMapSequential
has a buffer size for some queue, but I don't understand why concatMap
doesn't need one.