users@jersey.java.net

jersey-apache-client connection pool configuration

From: Mike Boyers <mboyers_at_yahoo.com>
Date: Mon, 7 Jun 2010 09:08:13 -0700 (PDT)

I'm beginning work on a RESTful api that, in order to fulfill requests, will need to reach out to other apis (some RESTful themselves, some HTTP but not RESTful).

My main requirements for any HTTP requests (both RESTful and non-RESTful) made to other services are:
-Support keep-alives
-Support connection pooling
-Support maximum configurable sizes for connection pools
-Support fail-fast "connection pool timeouts" when a particular pool has reached its maximum configured size
-If a pool grows under load, it needs to shrink again as load decreases
-Both RESTful and non-RESTful request should share the same connection pools
-Ability to query for pool sizes and other statistics to expose via JMX

When using Apache's HttpClient in the raw, I know I can accomplish all of these goals. But that won't get me the jersey-client features I'd like to have, so I'd like to consider using the jersey-apache-client for all HTTP requests and just get the non-RESTful responses as Strings.

However, I'm not sure how I can configure the underlying MultiThreadedHttpConnectionManager to behave the way I want. Some of the methods I'm used to calling are:

setDefaultMaxConnectionsPerHost()
setConnectionTimeout() -- I know this is already supported and know how to configure it
closeIdleConnections()
deleteConnections()

And also HttpClientParameter's setConnectionManagerTimeout() method.

Any ideas?

Thanks,
Mike Boyers