I invoke an api with webClient in the projection, the api returns a Mono of String, with the below example the api is not invoked, any idea ?
@Component
@RequiredArgsConstructor
public class UserEventHandler {
private static final WebClientErrorHandler ERROR_HANDLER = WebClientErrorHandler.builder()
.isFunctionalStatus(PRECONDITION_REQUIRED::equals)
.build();
private final WebClient webClient;
@EventHandler
public Mono<String> on(UserCreated evt) {
return getUser().flatMap(it -> {
System.out.println(it);
return Mono.just(it);
});
}
public Mono<String> getUser() {
return webClient.get()
.retrieve()
.onStatus(HttpStatus::isError, ERROR_HANDLER::handleError)
.bodyToMono(String.class);
}
}