I'm writing a swing application with HttpClient 4.
I followed the standard approach by passing a ThreadSafeClientConnManager
to my shared HttpClient
instance for now. But now I would like to be able to execute multiple requests/downloads at the same time...
I found some examples with MultiThreadedHttpConnectionManager
for HttpClient 3.x
but can I use it for version 4.x ? If so how ? I tried it but without success...
Thanks ;)
CloseableHttpClient is the base class of the httpclient library, the one all implementations use. Other subclasses are for the most part deprecated. The HttpClient is an interface for this class and other classes. You should then use the CloseableHttpClient in your code, and create it using the HttpClientBuilder .
HttpClient is fully thread-safe when used with a thread-safe connection manager such as MultiThreadedHttpConnectionManager.
setMaxPerRoute(int max) – Set the total number of concurrent connections to a specific route, which is two by default.
PoolingHttpClientConnectionManager is a more complex implementation that manages a pool of client connections and is able to service connection requests from multiple execution threads. Connections are pooled on a per route basis.
In 4.x, the equivalent is Pooling connection manager. You can read more details on its usage in section Pooling connection manager here. I would also strongly suggest you to read this thread on their forum.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With