I have a doubt regarding the usage of webclient in cirumstances when you need to invoke another service which is slow in responding and then use its data to process something and return in the call to your own api. e.g. my doSometing method is called by service to retrive top order from a list.My service fetches the list from another service "order-service"
@RestController
public class TestController {
@Autowired
private TestService testService;
@GetMapping("/test")
public String doSomething() {
return WebClient.create()
.get()
.uri("http://localhost:9090/order-service")
.retrieve()
.bodyToMono(List.class)
.block().get(0).toString();
//may be do more processing on the list later.
}
As you can see , it currently blocks the calling thread which beats the purpose of async.Also , in future i might need to do more processing on this List before returning. Am i using webclient correctly(is it serving any purpose here)?