【问题标题】:Jersey Client : Using ConnectionKeepAliveStrategyJersey 客户端:使用 ConnectionKeepAliveStrategy
【发布时间】:2018-11-09 21:53:08
【问题描述】:

在 jersey 客户端应用 ConnectionKeepAliveStrategy for ApacheConnector 时需要帮助。

对于独立的 Apache 客户端,我们可以这样做 -

ConnectionKeepAliveStrategy myStrategy = new ConnectionKeepAliveStrategy() {

public long getKeepAliveDuration(HttpResponse response, HttpContext context) {
     //your strategy here..
}

};

CloseableHttpClient client = HttpClients.custom()
.setKeepAliveStrategy(myStrategy)
.build();

但我在使用 Jersey 客户端时找不到任何应用策略的方法。 尝试将上述功能类注册到 WebClient,但没有帮助。

有什么线索吗?

【问题讨论】:

    标签: apache jersey jersey-client connector


    【解决方案1】:

    球衣 2.29.1 added support for Apache HTTP Client ConnectionKeepAliveStrategy and ConnectionReuseStrategy。应该像这样使用ApacheConnector:

    clientConfig.property(ApacheClientProperties.KEEPALIVE_STRATEGY, myStrategy);
    

    【讨论】:

      猜你喜欢
      • 2011-01-09
      • 1970-01-01
      • 1970-01-01
      • 2014-12-08
      • 1970-01-01
      • 2014-12-24
      • 1970-01-01
      • 2014-04-16
      • 1970-01-01
      相关资源
      最近更新 更多