I am trying to call a rest api & accumulating result by using Flux & Webclient. I want to understand the execution of flatMap operator for below code.
- list - Contains 50000 element.
- restClient - It is a WebClient.
WebClient.builder().baseUrl(url).filter(ExchangeFilterFunctions.basicAuthentication(userId, pwd)).build() - restClient.getResult - return a Mono.
client.get().uri(uri).retrieve().bodyToMono(returnType)
First log is printing thread name as main for certain no. of element then it started to print reactor-http-nio-(thread-no). Second log is printing thread name as reactor-http-nio-(thread-no). Pls explain how does the thread execution & switching is happening here.
Flux.fromIterable(list)
.log()
.map(e -> e.trim())
.flatMap(e -> restClient.getResult(client, e, String.class))//e is being used to create uri
.log()
.subscribe(e -> result.add(e));