cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <dk...@apache.org>
Subject Re: HTTP Connection Pooling
Date Wed, 17 Dec 2008 16:15:03 GMT
On Wednesday 17 December 2008 6:46:42 am Adrian Corcoran wrote:
> Hi,
> What was the design decision behind using java.net.URL. Is there a reason
> that apache-commons-httpclient was not used?

There were several reasons for using the java URLConnection instead of 
httpclient.   

1) Dependencies: we already get a lot of flak for the number of dependencies.   
Why add another dependency when something built into the JDK works fine 99% 
of the time?  

2) At the time, I think httpclient was at 2.x version which really kind of 
sucked.   

3) Since we were targetting Java 5 and most of the HTTP issues in the JDK that 
httpclient was working around were fixed for Java 5, there wasn't much of a 
compelling reason to use httpclient over the Java 5 URLConnection.

4) Request streaming: doing proper streaming with httpclient is HARD with the 
way our transports work.   Really, the only way to do it is to used piped 
streams and two threads.     Basically, in CXF, it's expected that a 
transport provides an OutputStream that the soap message and stuff is written 
to as it's produced.   This works GREAT with URLConnect.getOutputStream().   
httpclient, on the otherhand works the other way.   You give it an 
InputStream (or other block like a byte[] or File) that it reads from.    
Thus, to wire it into CXF would require one of:

a) transport provides a ByteArrayOutputStream or similar that CXF writes to 
then at close time, that's converted to a Entity and written out.     Thus, 
no streaming which would impact performance.

b) transport provides a PipedOutputStream on the current thread and uses a 
background thread with the corresponding PipedInputStream.   This allows 
streaming, but requires thread switches and such.

That all said, once 4.0 comes out, I've thought about investigating it a bit 
more mostly for the NIO stuff which can be useful for the async calls.   

Dan


>
> Thanks,
>  Adrian
>
> On Mon, Dec 15, 2008 at 7:01 PM, Cyrille Le Clerc
> <cyrille.leclerc@pobox.com
>
> > wrote:
> >
> >
> > CXF relies on the out-of-the-box java.net URL and HttpURLConnection .
> >
> > The JVM offers connections pooling mechanisms called "HTTP Persistent
> > Connections". Basically, you have to define the JVM property
> > "http.maxConnections" (default 5) to a higher value.
> >
> > Details are available here :
> > http://java.sun.com/javase/6/docs/technotes/guides/net/http-keepalive.htm
> >l
> >
> > Hope this helps,
> >
> > Cyrille
> > --
> > Cyrille Le Clerc
> > cleclerc@xebia.fr
> >
> > pashpour wrote:
> > > Hi folks,
> > >    Any luck with HTTP pooling?
> > >
> > > Thanks,
> > >
> > > Pash
> > >
> > > Simon MaticLangford wrote:
> > >> Hi,
> > >>
> > >>
> > >>
> > >> Is there anyway to get CXF to use an HTTP connection pool? Looking at
> >
> > the
> >
> > >> connection factory it appears to use url.openConnection() directly,
> > >> but wondered if there is a way other that writing my own
> > >> implementation of the interface? Specifically I want to reuse
> > >> connections using a client certificate over SSL due to the overhead of
> > >> establishing SSL
> >
> > connections.
> >
> > >> Thanks
> > >>
> > >>
> > >>
> > >> Simon
> > >>
> > >>
> > >>
> > >>
> > >>
> > >> Simon Matić Langford
> > >>
> > >> Java Development Lead
> > >>
> > >> www.betfair.com <http://www.betfair.com/>
> > >>
> > >>
> > >>
> > >> Waterfront | Hammersmith Embankment | Chancellors Road | London | W6
> > >> 9HP
> > >>
> > >>
> > >>
> > >> The information in this e-mail and any attachment is confidential and
> > >> is intended only for the named recipient(s). The e-mail may not be
> >
> > disclosed
> >
> > >> or used by any person other than the addressee, nor may it be copied
> > >> in any way. If you are not a named recipient please notify the sender
> > >> immediately and delete any copies of this message. Any unauthorized
> > >> copying, disclosure or distribution of the material in this e-mail is
> > >> strictly forbidden. Any view or opinions presented are solely those of
> > >> the author and do not necessarily represent those of Betfair. Betfair
> > >> is the trading name of The Sporting Exchange Limited whose registered
> >
> > office
> >
> > >> is: Waterfront, Hammersmith Embankment, Chancellors Road, London W6
> > >> 9HP. Registered in England with No. 3770548.
> > >>
> > >>
> > >> ______________________________________________________________________
> > >>__ In order to protect our email recipients, Betfair Group use SkyScan
> > >> from MessageLabs to scan all Incoming and Outgoing mail for viruses.
> > >>
> > >> ______________________________________________________________________
> > >>__
> >
> > --
> > View this message in context:
> > http://www.nabble.com/HTTP-Connection-Pooling-tp18319313p21019615.html
> > Sent from the cxf-user mailing list archive at Nabble.com.



-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog

Mime
View raw message