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

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.
主站蜘蛛池模板: 藁城市| 西盟| 舞阳县| 鱼台县| 灌南县| 岳普湖县| 凌云县| 崇义县| 三穗县| 瓦房店市| 营山县| 孟州市| 鞍山市| 图片| 淄博市| 莎车县| 永春县| 赤壁市| 呼和浩特市| 民丰县| 湖北省| 福安市| 清远市| 平山县| 额尔古纳市| 清水县| 正定县| 和平区| 凉城县| 普洱| 墨脱县| 渝北区| 黑龙江省| 响水县| 玛纳斯县| 林西县| 漠河县| 中西区| 崇仁县| 盐源县| 光泽县|