On Thu, 2009-03-19 at 14:13 +0200, Dobri Kitipov wrote: > Hi everybody, > when we reuse HTTPClient underneath each subsequent call to > HttpClient.executeMethod() will go to the connection manager > (MultiThreadedHttpConnectionManager) and ask for an instance of > HttpConnection. I have tested some use cases when a HTTPClient is reused for > invocation of a single WS and I can verify there is socket reuse. So far so > good. > > Anyway, my question is: could we expect any problems when reusing HTTPClient > among different threads calling different WSs which are deployed at > different hosts/servers?
HttpClient is fully thread-safe when used with a thread-safe connection manager. > As stated at - http://hc.apache.org/httpclient-3.x/threading.html - there is > a test case that demonstrates how HTTPClient can be reused among different > threads which in turn invoke different web services (WSs). My concern is > that HTTPClient has HttpState which I am not sure could be reused/shared > among different WSs invocations (JavaDoc says for HttpState: "A container > for HTTP attributes that may persist from request to request, such as > {...@link > Cookie cookies} and authentication {...@link Credentials credentials}.")? Can > different WS clients share one HttpClient and its HttpState among different > threads and invoking different WSs (e.g. at differnet hosts)? > Yes, they can. Maintain a separate instance of HttpState per execution thread and pass it as a parameter to the HttpClient#executeMethod Hope this helps Oleg > Thank you in advance, > Dobri --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
