简体   繁体   English

Mono之间如何正确交互?

[英]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:我的问题是:

  • is this a good implementation or it's a blocking one that waste the feature of Reactive programming?这是一个很好的实现还是一个浪费响应式编程特性的阻塞实现?
  • There is a better way to do it?有更好的方法吗?
  • I couldn't find a clear list of non-blocking/blocking operations, anybody knows if there is one?我找不到一份清晰的非阻塞/阻塞操作列表,有人知道是否有吗?

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 .我认为:如果childrenList类型,最好将其设置为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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM