hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Boris Granveaud <boris.granve...@europages.com>
Subject How to close persistent non-idle connections after some time
Date Wed, 18 Sep 2013 09:39:01 GMT
Hi,

I would like to automatically close persistent connections after some 
time, *even if they are used* (but only at the end of a query of course).

I need this so that when I would like to deploy a new middle server, I 
can remove it from the production pool of servers and wait for example 
60 seconds that the front webapps close their persistent HttpClient 
connections.

I have seen that you can set a timeToLive parameter in 
PoolingHttpClientConnectionManager but this is used only to close idle 
connections.

I cannot use ConnectionReuseStrategy and KeepAliveStrategy because I 
don't have access to the connection that is used.

Finally, I tried to extend PoolingHttpClientConnectionManager to remove 
the call to updateExpiry in releaseConnection:

     public void releaseConnection(
             final HttpClientConnection managedConn,
             final Object state,
             final long keepalive, final TimeUnit tunit) {
...
                 if (conn.isOpen()) {
                     entry.setState(state);
                     entry.updateExpiry(keepalive, tunit != null ? tunit 
: TimeUnit.MILLISECONDS);

but this is not feasible as CPoolEntry and CPoolProxy which are used in 
this method are not public classes.

Any idea?

Thanks,
Boris.


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message