hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Proper Use of HTTPClient 3.x for Many Hosts
Date Mon, 26 Jan 2009 19:09:30 GMT
joeweder wrote:
> Thanks Oleg! 
> But I am confused; how can a single HttpClient instance work for many hosts
> (e.g., http://abc.com, and https://xyz.com:3331) when it seems to have a
> single instance of HostConfiguration?
> 
> 

HttpClient 3.x API is awful. This is the reason I have been urging 
people to consider migrating to Httpclient 4.0 even though it is still 
formally in BETA.

Anyways, you can always pass a different instance of HostConfiguration 
to the HttpClient#execute method which will take precedence of the 
default HostConfiguration. Just make sure to use _relative_ request URIs 
in that case.

Hope this helps

Oleg


> 
> olegk wrote:
>> On Fri, 2009-01-23 at 11:45 -0800, joeweder wrote:
>>> I have a application that will talk to several hosts (from 1 to 25). For
>>> each
>>> host, it will make repeated (timed interval) ongoing GETs and POSTs to a
>>> few
>>> ports.
>>>
>>> QUESTION: What is the recommended usage of the
>>> HttpClient/HttpConnectionManager for this scenario?
>>>
>>> Do I use a single HttpConnectionManager for each host (20 hosts ==> 20
>>> HCM)?
>>> Or, can I reuse one HttpConnectionManager and talk to more than one host
>>> (20
>>> host ==> 1 HCM)?
>>>
>> Yes, you can (and should) reuse one connection manager. 
>>
>>
>>> I am reasonably certain that I need to use the
>>> MultiThreadedHttpConnectionManager.
>>> What I think is that I'd create one connection manager and create a
>>> single
>>> HttpClient instance for each host/port combination... like below:
>>>
>>> HttpConnectionManager      HttpClientHost1Port3331
>>>                                       HttpClientHost1Port8080
>>>                                       HttpClientHost2Port3331
>>>                                       HttpClientHost2Port8080
>>>                                       ...
>>>
>>> Agree/Disagree?
>>>
>> This will not result in any tangle benefit I can think of. A single
>> HttpClient instance should be perfectly okay.
>>
>>>  
>>> I see lots of posts about this but I am not 100% sure about the answer
>>> for
>>> my scenario.
>>> Thanks for any feedback in advance. 
>>>
>>> NOTE: I want to solve this with 3.x and then move to 4.x
>> 4.0 has a massively better connection management. If you plan to migrate
>> soon, skip 3.x altogether.
>>
>> Oleg
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
>>
>>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message