[英]How to correctly interact between Mono?
I'm new using the Spring Webflux and I was able to join the results between two rest API with the code:我是 Spring Webflux 的新手,我能够使用代码加入两个 rest API 之间的结果:
return item.zipWith(children).flatMap(tuple -> {
tuple.getT1().setItems(tuple.getT2());
return Mono.just(tuple.getT1());
});
Item is a Mono and children a Mono<List>. Item 是一个 Mono,子项是一个 Mono<List>。 My questions are:我的问题是:
In my opinion: If children
is List
type, it is better to make it as a Flux
type is better, and you could use Flux.fromIterable(List)
method to transform List
to Flux
.我认为:如果children
是List
类型,最好将其设置为Flux
类型更好,您可以使用Flux.fromIterable(List)
方法将List
转换为Flux
。
Therefor, the children
can receive elements and be delivered into item
non-blocking.因此, children
可以接收元素并以非阻塞方式传递到item
中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.