4

In a controller I can write:

fun update(@RequestBody myPojo: MyPojo): Mono<Void> 

or

fun update(@RequestBody myPojo: Mono<MyPojo>): Mono<Void> 

is there any difference? will the body parsing be done in different threads? in first case will i block the main reactor thread until myPojo is parsed?

piotrek
  • 13,982
  • 13
  • 79
  • 165

1 Answers1

4

There's no strong runtime difference between the two; in the first case, Spring will unwrap the incoming Mono, but the decoding will still happen asynchronously.

The only difference is that without a Mono type as an argument, you won't be able to use Reactor operators on it. So this is really about what needs to be achieved in your controller handler.

Brian Clozel
  • 56,583
  • 15
  • 167
  • 176