泽西客户端。使用ConnectionKeepAlive策略

问题描述 投票:2回答:1

需要帮助在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,但没有任何帮助。

有什么线索吗?

apache jersey jersey-client connector
1个回答
0
投票

Jersey 2.29.1 增加了对Apache HTTP客户端的支持 ConnectionKeepAliveStrategyConnectionReuseStrategy. 应该是这样工作的 ApacheConnector:

clientConfig.property(ApacheClientProperties.KEEPALIVE_STRATEGY, myStrategy);
© www.soinside.com 2019 - 2024. All rights reserved.