hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Flavio Oliveira <nve...@live.com>
Subject RE: releaseConnection() vs getConnectionManager().shutdown()
Date Thu, 29 Nov 2012 13:56:52 GMT

Oleg,

Definitely, thank you for clarifying.

By the way, I am going to do http get in different services (at same host or not). 
So as I only have one instance of the HTTP Client, can I have different 
threads with different timeout values sharing the same httpClient 
instance without any side effect? 

                HttpParams params = httpClient.getParams();
                HttpConnectionParams.setConnectionTimeout(params, timeout);
                HttpConnectionParams.setSoTimeout(params, timeout);
                HttpResponse response = httpClient.execute(httpget, context);

Regards, Flavio

> Subject: Re: releaseConnection() vs getConnectionManager().shutdown()
> From: olegk@apache.org
> To: httpclient-users@hc.apache.org
> Date: Thu, 29 Nov 2012 14:29:48 +0100
> 
> On Wed, 2012-11-28 at 15:16 +0000, Flavio Oliveira wrote:
> > Hi,
> > 
> > I use an instance of HttpClient to execute multiple methods from multiple threads.
> > 
> >         cm = new PoolingClientConnectionManager();
> >         cm.setMaxTotal(20);
> >         httpclient = new DefaultHttpClient(cm);
> > 
> > I release the connection by calling releaseConnection() on the method after the
response body has been read.                
> > 
> >          // Release connection
> >          EntityUtils.consume(entity);
> >          httpget.releaseConnection();
> >          
> > As I am using the PoolingClientConnectionManager I am not sure if I still need to
call "httpclient.getConnectionManager().shutdown()"
> > because I released the connection by calling releaseConnection(). Could someone
clarify that?
> > 
> > Regards, Flavio 		 	   		  
> 
> Flavio,
> 
> The #shutdown() method needs to be called once you are completely done
> with using the connection manager and would like to have all the
> connections kept alive in the pool shut down immediately and all
> resources associated with them released. Basically you need to do it
> only once it the HttpClient life cycle, upon termination.
> 
> Hope this helps
> 
> Oleg
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 
 		 	   		  
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message