The groupBy operator

The groupBy() operator converts the Flux<T> into batches. The operator associates a key with each element of the Flux<T>. It then groups elements that have the same key. These groups are then emitted by the operator. This is depicted in the following diagram:

It is important to note that elements may lose their original sequence order once they are grouped. The order is enforced by the logic of the key generation. Since each element is only associated with one key, the generated groups are not empty. All the generated groups are disjointed by nature. Let's try to generate some groups for our Fibonacci series:

    @Test public ...

Get Hands-On Reactive Programming with Reactor now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.