Below code compiles fine:
@Override
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
........
.flatMap(user-> {
userRepository.save(user).subscribe();
return chain.filter(exchange);
});
......
chain.filter(exchange) whose return type is Mono(Void) delegates to the next web filter in the chain.
But I need to invoke the line return chain.filter(exchange); after successful completion of userRepository.save otherwise it fails to save the user when next webfilter runs.
I tried below code but it does not even compile.
.flatMap(user-> {
userRepository.save(user).subscribe(u -> chain.filter(exchange) );
});
How to fix this problem?