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

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.
主站蜘蛛池模板: 浠水县| 巴南区| 崇礼县| 苍梧县| 丹棱县| 湖北省| 海安县| 大兴区| 泸州市| 永安市| 鹤岗市| 军事| 报价| 南丹县| 通化县| 会东县| 大余县| 澜沧| 阳春市| 扎鲁特旗| 永安市| 荔波县| 嵊州市| 教育| 德清县| 益阳市| 大姚县| 卓尼县| 平陆县| 临桂县| 南召县| 康定县| 奈曼旗| 凤山县| 拉孜县| 西和县| 肃北| 鹤壁市| 德惠市| 深圳市| 天峨县|