...
- Do not block in any of handlers which are passed to operators defined by Reactor. The library uses few a set of Schedulers (think thread-pools) which are suitable for different jobs. More details can be found in the documentation. If possible try to use non-blocking APIs.
- Most of operators support back-pressure. That means that a demand for new messages will be signalized from downstream subscribers. For instance if you have a
flux.flatMap(this::doThis).map(this::doThat).subscribe()
then ifdoThis
is very slow it will not request many items from sourceflux
and it will emit items at it's own pace fordoThat
to process. So usually there will be no buffering nor blocking needed betweenflux
anddoThis
. - (Almost) nothing will happen without subscribing to the Flux/Mono. These reactive streams are lazy, so the demand will be signaled only when subscription is being made ie. by means of
subscribe
orblock*
methods. - If you are going to go fully-reactive then you should probably not call subscribe/block anywhere in your code. For instance, when using Reactor Netty or Spring Web Flux you should return Mono/Flux from your core methods and it will be subscribed somewhere by the library you are using.
...