Spring webflux controller: consuming POJO vs Mono?

piotrek :

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?

Brian Clozel :

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.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=77740&siteId=1