官术网_书友最值得收藏!

Mono

Mono is another type of Reactor can emit only one item at the most. An asynchronous task that just wants to signal completion can use a Mono. Mono mainly deals with a stream of one element, as opposed to Flux's N elements.

Both Flux and Mono make use of this semantic by coercing to the relevant type when using some operations. For example, concatenating two Monos together will produce a Flux; on the other hand, calling single() on Flux<T> will return a Mono <T>.

Both Flux and Mono are Reactive Streams (RS) publisher implementations and conform to Reactive-pull back pressure.

Mono is used in specific scenarios like an HTTP request that produces only one response. In such cases, using Mono would be the right choice.

Returning a Mono<HttpResponse> for an HTTP request like the scenario mentioned earlier is better than returning a Flux<HttpResponse>, as it offers only operators that are relevant to a context of zero items or one item.

Mono can be used to represent no-value asynchronous processes that only have the concept of completion.
主站蜘蛛池模板: 延安市| 垣曲县| 开远市| 海盐县| 通江县| 宣武区| 乌拉特后旗| 清河县| 包头市| 长治县| 禹城市| 九龙坡区| 海原县| 安塞县| 宝兴县| 淅川县| 金山区| 柏乡县| 迭部县| 宜城市| 益阳市| 富锦市| 阿图什市| 海晏县| 汶上县| 兰坪| 雷波县| 革吉县| 稷山县| 申扎县| 资溪县| 油尖旺区| 临沂市| 精河县| 永兴县| 南郑县| 蒙阴县| 道真| 中方县| 特克斯县| 龙南县|