可执行代码:
```
@
PostMapping("/test")
public void postUrl(HttpServletRequest req) {
final AsyncContext ctx = req.startAsync();
List<String> respList = new ArrayList<>();
int taskNum = 10;
CountDownLatch countDownLatch = new CountDownLatch(taskNum);
for (int i = 0; i < taskNum; i++) {
VertxHttpClientUtil httpClientUtil = new VertxHttpClientUtil();
httpClientUtil.post("
https://baidu.com", (resp) -> {
respList.add(resp);
countDownLatch.countDown();
});
}
CompletableFuture.supplyAsync(() -> {
try {
countDownLatch.await();
System.out.println("finish..");
ctx.getResponse().getWriter().print(respList.get(0));
ctx.complete();
} catch (Exception e) {
e.printStackTrace();
}
return null;
});
}
```
CompletableFuture ,请自行设置 50-200 个线程,瓶颈在于 CompletableFuture 的线程数和你第三接口的吞吐量了。