Multi-threaded requests

Supporting Artefacts

Apache Commons Http Client - 2 minute tutorial

Efficient usage : How to efficiently use http client from multiple threads

This example shows how to set-up http client for use in a multi-threaded scenario efficiently.

The http-client framework allows one to configure the MultiThreadedHttpConnectionManager with the global maximum number of http conenctions that it can pool and also the host-level maximum number of http conenctions that it can keep in pool through methods setMaxTotalConnections and setDefaultMaxConnectionsPerHost respectively of class org.apache.commons.httpclient.params.HttpConnectionManagerParams. Apart from this , the global values of connection timeout and read timeout can be set.

In addition to this, the commons http-client framework, also gives the flexibility to configure the maximum number of connections and timeouts at specific host level through the class org.apache.commons.httpclient.HostConfiguration as shown below.