【发布时间】:2020-10-02 14:15:11
【问题描述】:
我正在开发一个 RESTful 服务,该服务使用固定的执行程序池来处理出站呼叫请求,例如:
return CompletableFuture
.supplyAsync(() -> {
try {
return restTemplate.exchange(uri, method, request, responseType, new Object[0]);
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
}
return null;
}, pool); //This is a thread pool executor with a fixed size
}
这个 restTemplate 还通过 PoolingHttpClientConnectionManager 指定了一个固定的连接池(有很多样板文件我不会包括在内)。
我将此解释为不必要地从发起线程卸载出站调用,这些线程被连接线程阻塞并且在此期间不执行任何其他任务。但是我无法说服这个坚持在涉及日志等辅助任务时提高性能的作者(我认为应该是这里卸载的任务)
我在这里错过了什么?
【问题讨论】:
标签: java spring rest web-services