5

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 endpoints:

@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 methods in reactive point of view.

lkatiforis
  • 5,703
  • 2
  • 16
  • 35
user1409534
  • 2,140
  • 4
  • 27
  • 33

1 Answers1

6

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.
lkatiforis
  • 5,703
  • 2
  • 16
  • 35
  • 1
    But i wonder why would Mono account be useful. If the purpose of using Mono, is to allow us to declare logic to be executed after account is deserialized, but wouldn't it be the same if we wait for the account to be deserialized and then invoke the controller's logic – Nick Wills Oct 11 '22 at 17:22