0

我正在尝试使用 restTemplate 同时执行两个(或更多)REST Web 服务以提高性能,所以我希望它们同时执行,我如何使用 spring MVC 做到这一点?

我的意思不是第一个 Web 服务 + 第二个 Web 服务(2 秒 + 2 秒),我将在 2 秒内同时运行两个 Web 服务......

@GetMapping("/findClient/{name}")
public String findClient(@PathVariable String name) {

    String result1 = restTemplate.getForObject("http://localhost:8080/api/getClient1/"+name,String.class);

    String result2 = restTemplate.getForObject("http://localhost:8080/api/getClient2/"+name,String.class);

    String result = result1 + result2;
    return result;
}
4

0 回答 0