hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pedro Ribeiro <ribei...@gmail.com>
Subject Re: Open connections keepalive.
Date Thu, 19 Feb 2015 14:10:09 GMT
Hi Oleg,

Thank you very much for your reply.

That's exactly what I was thinking, but instead of using enumAvailable
which blocks access to the pool, I would lock and get a copy of *available*
 List*.* Then, for each connection available, try to lease one by one.
If the connection is not available anymore (we might have stale information
because we are outside the lock) continue otherwise send a keep-alive.

Would you be interested in a patch for this feature?

On Thu, Feb 19, 2015 at 1:33 PM, Oleg Kalnichevski <olegk@apache.org> wrote:

> On Wed, 2015-02-18 at 19:46 +0000, Pedro Ribeiro wrote:
> > Hi,
> >
> > I'm using http client with a connection pool to execute RPCs in a remove
> > host which drops connections after 1 min of inactivity.
> > In my use case It’s really expensive to establish new connections so I
> > would like to send a keepalive message from every open connection before
> > expiration.
> >
> > I've looked into the source of PoolingHttpClientConnectionManager and
> > unfortunately I didn't find a way to implement this feature reusing
> > existing pool implementation. I though in wrapping
> > PoolingHttpClientConnectionManager and assigning a state to uniquely
> > identify connections and request them when they are about to expire but
> > it’s not the way to go. The state of the connection wasn't meant to be
> used
> > this way.
> >
> > I don’t see any other option other than changing
> > org.apache.http.pool.AbstractConnPool and add a new method with a
> callback
> > to run on every active connection.
> > I cannot use org.apache.http.pool.AbstractConnPool.enumAvailable because
> > it’s too expensive. It locks the pool while the callbacks are running. I
> > was thinking in copying the list of available connections (with lock) and
> > try to lease and send my request one by one.
> >
> > Any other suggestion?
> >
> > Thank you.
>
> Pedro,
>
> Please note that when kept in the pool persistent connections are not
> able to send or receive data. They are just sitting there idly not being
> attached to a particular thread of execution. This is a general
> limitation of the classic (blocking) Java I/O. In order to be able send
> and receive a keep-alive message one has to lease a connection from the
> pool (or do it from #enumAvailable for all connections blocking access
> to the pool from all other threads in the process).
>
> Oleg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

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