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

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.
主站蜘蛛池模板: 南漳县| 武义县| 长顺县| 阿拉善右旗| 天峨县| 曲水县| 越西县| 郯城县| 济源市| 湘乡市| 芜湖市| 张家口市| 乌兰浩特市| 甘德县| 新田县| 涡阳县| 交城县| 横山县| 泸水县| 平和县| 子洲县| 北票市| 绥宁县| 汝阳县| 连州市| 沧源| 五大连池市| 鲁甸县| 且末县| 武隆县| 塔城市| 土默特右旗| 泸定县| 乌鲁木齐县| 黑河市| 瑞金市| 卢氏县| 游戏| 蓝山县| 舒城县| 巴林右旗|