Ad

Spring WebFlux Reactive Input

- 1 answer

What is the difference between a controller that gets input regular java payload and that of reactive payload. For example Say I have the following 2 end point

@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

Ad

Answer

According to WebFlux documentation:

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.
  • Mono<Account> account — the controller can use the Mono to declare logic to be executed after the account is deserialized.
  • Flux<Account> accounts — input streaming scenario.
Ad
source: stackoverflow.com
Ad