On Wed, 2013-09-18 at 11:39 +0200, Boris Granveaud wrote:
> 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.
>
AbstractConnPool class, which CPool is based upon, provides #enumLeased
method that can be used to enumerate leased connections and optionally
close some or all of them. Truth to be told, I simply forgot to add a
corresponding method to PoolingHttpClientConnectionManager.
Please raise a change request in JIRA for this issue. For the time being
you will have to resort to reflection in order to get hold of the 'pool'
instance variable and cast it to AbstractConnPool.
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]