`buffer(3)` breaks a `Flux` into lists of at most three elements. The result is another `Flux`, which emits those lists instead of individual elements. section 11.3.3
Group five fruits
For `Flux.just("apple", "orange", "banana", "kiwi", "strawberry")`, calling `.buffer(3)` produces two lists: `[apple, orange, banana]` and `[kiwi, strawberry]`. `StepVerifier` can check both lists and completion. section 11.3.3
To process chunks in parallel, follow `buffer(3)` with `flatMap()`. Convert each list back to a `Flux`, transform its elements with `map()`, and use `subscribeOn(Schedulers.parallel())` for each resulting stream. `log()` makes their activity visible. section 11.3.3
@Test
public void bufferAndFlatMap() throws Exception {
Flux.just(
"apple", "orange", "banana", "kiwi", "strawberry")
.buffer(3)
.flatMap(x ->
Flux.fromIterable(x)
.map(y -> y.toUpperCase())
.subscribeOn(Schedulers.parallel())
.log()
).subscribe();
}
The complete fruit-stream example shows how buffering feeds parallel transformations. section 11.3.3
