My email had a problem with my last post...so here it goes.
Thanks to Mike and Eric, my questions are mostly answered, and I am now able
to explain some strange problems that I was seeing. It looks to me that
using the MultiThreadedHttpConnectionManager as the default is better as it
is less likely to burn some unsuspecting user.

I have another question to add:  How do I "prime" the connections in the
MultiThreadedHttpConnectionManager pool?  I am running into a problem where
it is taking a long time (almost 30 secs using https) to open the first
connection. As a result the session bean that is opening the connection is
timing out. I need a way to make the first call to create the connection
work without timing out. Any suggestion is welcome.

Thanks.
Om.

----- Original Message -----
From: "Michael Becke" <[EMAIL PROTECTED]>
To: "Commons HttpClient Project" <[EMAIL PROTECTED]>
Sent: Thursday, June 05, 2003 3:25 PM
Subject: Re: Questions related to the use of HttpClient classes


> Quite so.  I will get one started.  Any other questions you would like
> to see added?
>
> Mike
>
> On Thursday, June 5, 2003, at 04:59 PM, Oleg Kalnichevski wrote:
>
> > Mike,
> >
> > Why do not we indeed make a FAQ document out of this Q & A session
> > with?
> >
> > Oleg
> >
> > On Thu, 2003-06-05 at 22:18, Michael Becke wrote:
> >> Om,
> >>
> >> Nice set of questions.  Looks almost like a FAQ :)
> >>
> >>> 1. When I do "httpclient = new HttpClient", the object is created by
> >>> default
> >>> with the SimpleHttpConnectionManager.
> >>
> >> Correct.
> >>
> >>> 2. I create "post = new PostMethod(url)" and call
> >>> httpclient.executeMethod(post). At this point httpclient takes the
> >>> url in
> >>> the post object and using the SimpleHttpConnectionManager, creates a
> >>> HttpConnection object.  This connection is retained by the
> >>> SimpleHttpConnectionManager and (possibly?) reused.
> >>
> >> Yes, that's pretty much it.  Just to clarify
> >> SimpleHttpConnectionManager
> >> contains a single instance of an HttpConnection and reuses it when
> >> possible.  For example if you were to do two GETs from
> >> "http://jakarta.apache.org/"; then the connection would be reused.
> >> This
> >> assumes that the server supports connection persistence.
> >>
> >>> 3. After connection is established, data is posted, and the result
> >>> retrieved
> >>> 4. I do post.releaseConnection().  Does the connection get closed at
> >>> this
> >>> point? Is the HttpConnection object still around? What do I need to
> >>> do if  I
> >>> had wanted to have the connection stay alive (because it takes time
> >>> to
> >>> re-establish the connection)?
> >>
> >> It depends on the server and a few other variables (like SSL and JVM
> >> version).  In general HTTP 1.1 defaults to keep-alive and 1.0 defaults
> >> to close.  These defaults can be overriden by the server using the
> >> connection header.
> >>
> >>> 5. Is post.recycle() related to connection in any way? What is the
> >>> purpose
> >>> of this? Is PostMethod ctor an expensive operation?
> >>
> >> It calls releaseConnection() plus some other things.  In general I do
> >> not use recycle much.  I prefer to create a new instance as it's not
> >> particularly expensive.
> >>
> >>> 6. SimpleHttpConnectionManager doc says "This manager makes no
> >>> attempt to
> >>> provide exclusive access to the contained HttpConnection". Does this
> >>> mean
> >>> that calling httpclient.execute() method in this case is not
> >>> thread-safe?
> >>
> >> Correct.  Not thread safe.  It would fail quite quickly if used from
> >> multiple threads.
> >>
> >>> 7. If I wanted to use "connection pooling" should I be using
> >>> MultiThreadedHttpConnectionManager instead?  Or do I need to
> >>> implement my
> >>> own pooling?
> >>
> >> MultiThreadedHttpConnectionManager is what you want.
> >>
> >> Mike
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail:
> >> [EMAIL PROTECTED]
> >> For additional commands, e-mail:
> >> [EMAIL PROTECTED]
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
[EMAIL PROTECTED]
> For additional commands, e-mail:
[EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to