简体   繁体   English

Spring WebFlux 无功输入

[英]Spring WebFlux reactive input

What is the difference between a controller that gets input regular java payload and that of reactive payload.获取输入常规 java 有效负载的 controller 与反应有效负载之间有什么区别。 For example Say I have the following 2 end point例如说我有以下2个端点

@RestController
public class MyController {
@PostMapping
public Flux<SomeObject> doThing(@RequestBody MyPayload playlod) {
// do things that return flux - reactive all the way from this controller

and this one和这个

    @RestController
    public class MyController {
   @PostMapping
   public Flux<SomeObject> doThing(@RequestBody Mono<MyPayload> playlod) {
   

I don't understand the difference between the 2 method in reactive point of view从反应的角度来看,我不明白 2 方法之间的区别

According to WebFlux documentation :根据 WebFlux 文档

The request body can be one of the following way and it will be decoded automatically in both the annotation and the functional programming models:请求正文可以是以下方式之一,它将在注解和函数式编程模型中自动解码:

  • Account account — the account is deserialized without blocking before the controller is invoked. Account account ——在调用 controller 之前,账户被反序列化而不阻塞。
  • Mono<Account> account — the controller can use the Mono to declare logic to be executed after the account is deserialized. Mono<Account> account — controller 可以使用 Mono 声明要在帐户反序列化后执行的逻辑。
  • Flux<Account> accounts — input streaming scenario. Flux<Account> accounts ——输入流场景。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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