Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HttpClient 4 - What happened to MultiThreadedHttpConnectionManager?

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 ;)

like image 527
Hervé Donner Avatar asked Dec 19 '11 01:12

Hervé Donner


People also ask

What is the difference between HttpClient and CloseableHttpClient?

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 .

Is HttpClient multithreaded?

HttpClient is fully thread-safe when used with a thread-safe connection manager such as MultiThreadedHttpConnectionManager.

What is setMaxPerRoute?

setMaxPerRoute(int max) – Set the total number of concurrent connections to a specific route, which is two by default.

What is the use of PoolingHttpClientConnectionManager?

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.


1 Answers

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.

like image 166
Aravind Yarram Avatar answered Sep 22 '22 19:09

Aravind Yarram