I am using RestClient to connect to a remote JSON API.
Previously, in Spring 3.0, I was using Commons HTTPClient.
I found that performance was low due to a lot of locking in the old multithreaded connection manager.
I now want to try Apache HttpComponents 4.2 since it appears they fixed up the locking.
I would like to use the PoolingClientConnectionManager as the constructor parameter for the DefaultHttpClient that will be autowired for the different classes.
The challenge is setting up the PoolingClientConnectionManager connection manager. I want a high number of concurrent connection to the JSON API provider. These use HttpRoute objects to represent the hostname. But, as described in http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/conn/PoolingClientConnectionManager.html, PoolingClientConnectionManager uses a setMaxPerRoute(HttpRoute, int maxConnections) method.
How can I set up the connection manager a Spring context.xml file, since it doesn’t use simple setters?
How about wrapping the PoolingClientConnectionManager by extending it, and then creating setters using a Bean representing a route/max value. Ie.
..then in your Spring config you can set the routeMax property using your RouteMax bean.