I'm using WebFlux, and I want to log with AOP as follow:
Class LogAop {
@AfterReturning("execution ...")
public void configSetted() {
// Getting username by token
Mono<Sting> username = ReactiveSecurityContextHolder.getContext()
.map { ... };
username.subscribe ({it -> loggerin.info(it);});
}
}
In the above code, I want to log username, but there is no log. How can I subscribe to Mono
or Flux
without returning to the method?
Note: Some times I want to do differnt things on subscribe data, such as saving data in db.