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 "Wittmann Armin (BI)" <ar...@id.ethz.ch> on 2006/11/21 14:49:51 UTC

RE: usage of MultiThreadedHttpConnectionManager insideJ2EE-Framework

Hi Oleg

thank you for your fast answer. 

> Do not use MultiThreadedHttpConnectionManager inside an EJB container.
> Wrap an instance of HttpClient with a 
> SimpleHttpConnectionManager into a
> stateless session bean and let the EJB container do the connection
> pooling for you. 
This I have done so far :-)
and it works fine.
I am making for each reaquest a new instance of HttpClient and I am
instantianing it every time with a new instance of
SimpleHttpConnectionManager.

> 
> Make sure you reset the associated HttpState prior to each HTTP method
> execution, though
In the API I did not find out how to reset this state?
Can you help me?

Armin

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


RE: usage of MultiThreadedHttpConnectionManager insideJ2EE-Framework

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Tue, 2006-11-21 at 14:49 +0100, Wittmann Armin (BI) wrote:
> Hi Oleg
> 
> thank you for your fast answer. 
> 
> > Do not use MultiThreadedHttpConnectionManager inside an EJB container.
> > Wrap an instance of HttpClient with a 
> > SimpleHttpConnectionManager into a
> > stateless session bean and let the EJB container do the connection
> > pooling for you. 
> This I have done so far :-)
> and it works fine.
> I am making for each reaquest a new instance of HttpClient and I am
> instantianing it every time with a new instance of
> SimpleHttpConnectionManager.
> 

Actually you may want to re-use HttpClient and the associated connection
manager, especially if your application talks to the same target host
and you want to make use of persistent connections. Make HttpClient an
instance variable of the stateless session bean. The EJB container will
take care of the access synchronization. All you have to do is to make
sure the HTTP state information is reset prior to each new HTTP
request.  

> > 
> > Make sure you reset the associated HttpState prior to each HTTP method
> > execution, though
> In the API I did not find out how to reset this state?
> Can you help me?
> 

This is the simples approach:

httpclient.setState(new HttpState());

Oleg

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


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