Configuring Parameters Per Host/Route

View: New views
3 Messages — Rating Filter:   Alert me  

Configuring Parameters Per Host/Route

by John Kirollos :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello There
 
I'm new to HttpClient 4.0 in specific and to HttpClient in general, and
trying to figure out how to configure some parameters per host (I guess
I can say "route" interchangeably with "host").
 
It's obvious for me how to set parameters on the HttpClient level (such
as CONNECTION_TIMEOUT or TCP_NODELAY) and on the connection manager
level (such as the maximum total number of connections or the maximum
number of connections per route).
 
However, it's not so obvious how to set parameters such as the socket
timeout (SO_TIMEOUT) per host. Is this possible anyway?

I believe it'd be something around
HttpConnectionParamBean/HttpConnectionParams, but the problem is that I
cannot figure out how to use these 2 classes, and I even did not find
any usage for them in the HttpClient library.
 
I appreciate if someone can help.
 
Thanks in advance
John

Re: Configuring Parameters Per Host/Route

by olegk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sun, 2009-09-20 at 20:23 +0200, John Kirollos wrote:

> Hello There
>  
> I'm new to HttpClient 4.0 in specific and to HttpClient in general, and
> trying to figure out how to configure some parameters per host (I guess
> I can say "route" interchangeably with "host").
>  
> It's obvious for me how to set parameters on the HttpClient level (such
> as CONNECTION_TIMEOUT or TCP_NODELAY) and on the connection manager
> level (such as the maximum total number of connections or the maximum
> number of connections per route).
>  
> However, it's not so obvious how to set parameters such as the socket
> timeout (SO_TIMEOUT) per host. Is this possible anyway?
>
> I believe it'd be something around
> HttpConnectionParamBean/HttpConnectionParams, but the problem is that I
> cannot figure out how to use these 2 classes, and I even did not find
> any usage for them in the HttpClient library.
>  
> I appreciate if someone can help.
>  
> Thanks in advance
> John

John,

This section of HttpClient tutorial describes in details how HTTP
parameter hierarchy functions:

http://hc.apache.org/httpcomponents-client/tutorial/html/fundamentals.html#d4e316

In short, one can set parameters either at the HTTP agent level or the
HTTP request level. One can configure request level parameters
differently depending on the execution context, for instance based on
the request route / target host.

Hope this helps

Oleg



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


Re: Configuring Parameters Per Host/Route

by John Kirollos :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Oleg

Thanks for your answer. I see the following will do the job as well:

HttpGet httpGet = new HttpGet();

HttpParams httpGetParams = httpGet.getParams();

HttpConnectionParams.setSoTimeout(httpGetParams, 2000);

HttpConnectionParams.setStaleCheckingEnabled(httpGetParams, false);

/*//may set other parameters here...*/


Regards,
John

Oleg Kalnichevski wrote:

> On Sun, 2009-09-20 at 20:23 +0200, John Kirollos wrote:
>  
>> Hello There
>>  
>> I'm new to HttpClient 4.0 in specific and to HttpClient in general, and
>> trying to figure out how to configure some parameters per host (I guess
>> I can say "route" interchangeably with "host").
>>  
>> It's obvious for me how to set parameters on the HttpClient level (such
>> as CONNECTION_TIMEOUT or TCP_NODELAY) and on the connection manager
>> level (such as the maximum total number of connections or the maximum
>> number of connections per route).
>>  
>> However, it's not so obvious how to set parameters such as the socket
>> timeout (SO_TIMEOUT) per host. Is this possible anyway?
>>
>> I believe it'd be something around
>> HttpConnectionParamBean/HttpConnectionParams, but the problem is that I
>> cannot figure out how to use these 2 classes, and I even did not find
>> any usage for them in the HttpClient library.
>>  
>> I appreciate if someone can help.
>>  
>> Thanks in advance
>> John
>>    
>
> John,
>
> This section of HttpClient tutorial describes in details how HTTP
> parameter hierarchy functions:
>
> http://hc.apache.org/httpcomponents-client/tutorial/html/fundamentals.html#d4e316
>
> In short, one can set parameters either at the HTTP agent level or the
> HTTP request level. One can configure request level parameters
> differently depending on the execution context, for instance based on
> the request route / target host.
>
> Hope this helps
>
> Oleg
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@...
> For additional commands, e-mail: httpclient-users-help@...
>
>
>