You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Mike Williams <mt...@ntlworld.com> on 2007/04/15 13:13:19 UTC

MultiThreadedHttpConnectionManager

Hello all,

I'm currently using MultiThreadedHttpConnectionManager for a number of
connections. Each thread uses GetMethod via HttpClient.executeMethod to
obtain its data. However I'd like to have one particular connection to be
'reserved' and have priority over all other connections when required. 

I'm not sure how to approach the priority issue yet but I'm trying to
reserve a connection from the MultiThreadedHttpConnectionManager by calling
getConnectionWithTimeout() at the start of execution. This gives me a nice
HttpConnection to play with but the method I wish to use with it uses
GetMethod & executeMethod as stated earlier. Is there a way I can use the
HttpConnection object with HttpClient.executeMethod for that specific
connection?

Any advice on how to tackle this would be appreciated,

Regards,

Mike


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


Re: MultiThreadedHttpConnectionManager

Posted by Roland Weber <os...@dubioso.net>.
Hello Mike,

> However I'd like to have one particular connection to be
> 'reserved' and have priority over all other connections when required. 
> 
> Is there a way I can use the
> HttpConnection object with HttpClient.executeMethod for that specific
> connection?

None that I know of. Allthough your idea makes sense from a general
point of view, I doubt it will work with the specifics of the rather
special, and occasionally screwed, HttpClient 3.x API.

If in your place, I would create two HttpClient objects with separate
connection managers. One with many connections for the regular stuff,
and another one with a single connection for the prioritized stuff.
You can use HttpClient.setState() to assign the same default state
to both HttpClient objects. Use MTHCM for both, even though one of
them has only a single connection to manage. MTHCM is thread safe,
while SimpleHttpConnectionManager is not.

hope that helps,
  Roland



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