需要帮助在jersey客户端中为ApacheConnector应用ConnectionKeepAliveStrategy。
对于独立的Apache客户端,我们可以这样做----。
ConnectionKeepAliveStrategy myStrategy = new ConnectionKeepAliveStrategy() {
public long getKeepAliveDuration(HttpResponse response, HttpContext context) {
//your strategy here..
}
};
CloseableHttpClient client = HttpClients.custom()
.setKeepAliveStrategy(myStrategy)
.build();
但我找不到任何方法在使用Jersey Client时应用策略.尝试将上述功能类注册到WebClient,但没有任何帮助。
有什么线索吗?
Jersey 2.29.1 增加了对Apache HTTP客户端的支持 ConnectionKeepAliveStrategy
和 ConnectionReuseStrategy
. 应该是这样工作的 ApacheConnector
:
clientConfig.property(ApacheClientProperties.KEEPALIVE_STRATEGY, myStrategy);