My project is completely a Synchronized Web Application and i'm try to use netty server to save resource since it is using event loop for each request.
Now my requirement is to make a sync(blocking) external api call and for that I'm using WebClient with .block() at the end. But i'm getting below error
block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-http-nio-6
Here is my code
Mono<Map<String,Object>> resMono=wc.post().body(Mono.just(bodyStr), String.class)
.retrieve().bodyToMono(new ParameterizedTypeReference<Map<String, Object>>() {})
.subscribeOn(Schedulers.boundedElastic())
.publishOn(Schedulers.boundedElastic())
//.subscribeOn(Schedulers.fromExecutor(webClientExecutor))
.timeout(Duration.ofSeconds(10)).log("info");
resMono.share().block();
// resMono.block();
I've tried with exchangeToMono and SubscribeOn, publishOn with Schedulars.boundedElastic() or custom executors. But nothing helps.
With resMono.share().block() works untill specific threshold and later when concurrent hits reach like 5 to 10, requests start hung (I assume, event loop is full at this point).
I aware that same WebClient code with .block() at end will work fine with Tomcat since it is sync server. But i'm tryng to do blocking call in netty application with WebClient.
Thanks in advance.
reactor-http-nio-6. Obviously, you cannot block inside that thread because it could freeze the whole app.