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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.