Thank you very much for the feedback. It's indeed much simpler. As you said, I can periodically access the PoolingHttpClientConnectionManager instance, request a couple of connections at the same time, send a HEAD request on all of them and finally return them back to the pool. I'll give a try.
To request a connection from the pool I need a route and state. To make this solution more generic I could wrap PoolingHttpClientConnectionManager, save all the hosts/states that are being used by my application and use this info to retrieve connections from the pool and send the HEAD requests. Pedro Ribeiro On Thu, Feb 19, 2015 at 7:17 PM, Michael Osipov <[email protected]> wrote: > Am 2015-02-19 um 15:33 schrieb Oleg Kalnichevski: > >> On Thu, 2015-02-19 at 14:10 +0000, Pedro Ribeiro wrote: >> >>> 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? >>> >>> >> Pedro, >> >> The problem with this approach is that one cannot lease a specific >> connection. One can only lease an arbitrary connection matching the >> lease criteria: route and state. >> >> A much simpler solution to your problem might be just leasing, say, 5 >> connections every 5 minutes, sending a ping message on all them and >> releasing them all back to the pool. This way your application would >> always have approximately 5 live connections. >> > > This is a good approach I would also recommend. The easiest way is with a > TimerTask which will issue a HEAD request. > > Michael > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
