Spring boot 3.0.2 - I want to block in reactor thread to validate an event. Unless the event is validated , I do not want to move ahead. How do we achieve it ?
.block() -> throws exception , so it cannot be used.
java.lang.IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-http-kqueue-7 at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:83) ~[reactor-core-3.5.2.jar:3.5.2] at reactor.core.publisher.Mono.block(Mono.java:1710) ~[reactor-core-3.5.2.jar:3.5.2]
Flux.fromIterable(messages).map((message) -> {
try {
return this.readValue(message);
} catch (Exception var3) {
throw new RuntimeException(var3);
}
}).flatMap(this::process).subscribeOn(Schedulers.boundedElastic()).doOnError((error) -> {
this.messageErrorHandler.handle(error);
}).blockLast(Duration.ofMillis(Long.parseLong((String)this.properties.get("blockLast.timeout.ms"))));
Validation is done inside process() method
eventValidator.validate(eventPayload);
validate makes IO call
Mono<Data> data = repo.getData();
So basically I want to block on this data.