hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Javier Ramos <jram...@gmail.com>
Subject Re: HttpCore/HttpClient services integration in a J2EE Servlet container
Date Wed, 15 Dec 2010 20:49:03 GMT
Hi Oleg,

Yes, it is nice to be able to monitor the number of connections in use.
Would be even better to have it per host.

Thanks again,

Javier

2010/12/15 Oleg Kalnichevski <olegk@apache.org>

> On Wed, 2010-12-15 at 17:44 +0100, Javier Ramos wrote:
> > Thanks, Oleg
> >
> > I understand that reusing an HttpClient instance is a recommended
> practice,
> > ┬┐right?
> >
> > If we push this reuse strategy to the limit then it should be best to
> have
> > just one HttpClient with a ThreadSafeClientConnManager in a servlet only
> > J2EE application (no EJB's).
> >
> > I am thinking of wrapping this client in a singleton with
> >
> > 1.- A method to configure the conection manager, to be called at context
> > initialisation (max connections per host, max total connections, etc).
> > 2.- A getter for the HttpClient instance, to be used everywhere in the
> > application where an HttpClient is required
> > 3.- A method to cleanup everything, to be called on context destroy
> (would
> > call shutdown on the connection manager).
> >
> > Does this setup make sense ?
> >
>
> Makes sense to me.
>
> > If it does, having just one instance of HttpClient would provide the
> > opportunity to monitor it from a servlet. Being able to check the number
> of
> > connections established with each host would be a very nice feature, for
> > example. Or modifying the max connections per host at runtime. However,
> in
> > the javadocs I do not find any methods that can allow this information to
> be
> > obtained. Is it by design or am I missing something ?
> >
>
> What about ThreadSafeClientConnManager#getConnectionsInPool?
>
>
> http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.html#getConnectionsInPool%28%29
>
> http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.html#getConnectionsInPool%28%29
>
> 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