2

Need help in applying ConnectionKeepAliveStrategy for ApacheConnector in jersey client.

For a standalone Apache Client, we can do it this way -

ConnectionKeepAliveStrategy myStrategy = new ConnectionKeepAliveStrategy() {

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

};

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

But I couldn't find any way to apply strategy while using Jersey Client. Tried registering the above feature class to WebClient but that did not help.

Any leads ?

Nikhil
  • 191
  • 1
  • 6

1 Answers1

0

Jersey 2.29.1 added support for Apache HTTP Client ConnectionKeepAliveStrategy and ConnectionReuseStrategy. Should work like this with ApacheConnector:

clientConfig.property(ApacheClientProperties.KEEPALIVE_STRATEGY, myStrategy);