1

I have an existing spring-mvc application with different @RestController. Now I want to add a Mono<String> endpoint, and log the request timestamp with url path, as well as the response timestamp.

But how? I cannot simply @EnableWebFlux as I would have to disable spring-mvc therefor.

How could I register a filter explicit for the webflux endpoint that catches on invocation, and right before the response is written back async?

@RestController
public class FluxService {
   @PostMapping
   public Mono<String> post() {
         return webClient.post().uri(uri).bodyValue(payload).retrieve().bodyToMono(String.class);
   }
}

I want enhanced logging on the @PostMapping endpoint, not on the webClient!

membersound
  • 81,582
  • 193
  • 585
  • 1,120

1 Answers1

0

MVC is a blocking/servlet based api, mixing it with webflux isn't going to work. They use different filters, security etc as MVC assumes a lot of ThreadLocal stuff. (Can I use SpringMvc and webflux together?)

If you really want to mix them like this you could use .doOnNext() once you get your mono and call your logger there.

Adam Bickford
  • 1,216
  • 12
  • 14