I have implemented WebFilter for measuring roundtrip time of incoming request and to add MDC to context.
is there a way to get this worked ?
Problem:
WebFilter is not being called when i have both dependencies in my class path.
if i remove spring-boot-starter-web , every thing works fine.
Dependency being used :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
Code Implemented:
import org.springframework.web.server.WebFilter
@Component
public class RoundTrip implements WebFilter {
@Override
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
return chain.filter(exchange).doOnSuccess(r -> logWithContext(startTime));
}
}