Return-Path: Delivered-To: apmail-cxf-users-archive@www.apache.org Received: (qmail 72446 invoked from network); 8 Oct 2010 14:06:22 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 8 Oct 2010 14:06:22 -0000 Received: (qmail 32826 invoked by uid 500); 8 Oct 2010 14:06:22 -0000 Delivered-To: apmail-cxf-users-archive@cxf.apache.org Received: (qmail 32759 invoked by uid 500); 8 Oct 2010 14:06:21 -0000 Mailing-List: contact users-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@cxf.apache.org Delivered-To: mailing list users@cxf.apache.org Received: (qmail 32751 invoked by uid 99); 8 Oct 2010 14:06:21 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Oct 2010 14:06:21 +0000 X-ASF-Spam-Status: No, hits=0.7 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [64.85.173.253] (HELO server.dankulp.com) (64.85.173.253) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Oct 2010 14:06:13 +0000 Received: by server.dankulp.com (Postfix, from userid 5000) id 32EC3186EBE; Fri, 8 Oct 2010 10:05:52 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on server.dankulp.com X-Spam-Level: X-Msg-File: /tmp/mailfilter-users@cxf.apache.org.FRLzM50dSL Received: from dilbert.dankulp.com (c-24-91-72-253.hsd1.ma.comcast.net [24.91.72.253]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by server.dankulp.com (Postfix) with ESMTPSA id 18D1F186EBA; Fri, 8 Oct 2010 10:05:49 -0400 (EDT) From: Daniel Kulp To: users@cxf.apache.org Subject: Re: When transfering an object with a DataHandler field, is it OK not to read from the InputStream? Date: Fri, 8 Oct 2010 10:03:46 -0400 User-Agent: KMail/1.13.5 (Linux/2.6.35; KDE/4.5.2; x86_64; ; ) Cc: Benson Margulies , Jimi =?utf-8?q?Hulleg=C3=A5rd?= References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <201010081003.46516.dkulp@apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, score=-2.9 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=unavailable version=3.3.1 On Friday 08 October 2010 9:16:47 am Benson Margulies wrote: > On the wire, that blob has to travel as a MIME part. And there might > be several such MIME parts. Unless you traffic in interceptors, as far > as I know, the entire content will be pulled into memory, unless it's > very big, in which case it ends up in a temp file. CXF can't just > leave the socket that the data is arriving on sitting there waiting > for you to read the stream on the data handler. Actually, if it's the last MIME part that was asked for (that's a key point= ),=20 it WILL stream right off the socket. It won't get buffered. If something= =20 causes it to have to search for another mime part (like asking the attachme= nt=20 collection it's size), then it would get buffered, but for a normal "single= =20 attachment through JAXB or SWA" type case, it would stream. Spent a lot o= f=20 time getting that working correctly. :-) > 2010/10/8 Jimi Hulleg=C3=A5rd : > > I have set up a simple webservice for testing, where the object to > > transfer contains a bunch of simple fields, and then a DataHandler for > > some binary data (a Blob, actually). It works just fine, and some test > > with large files (500MB) proved to me that it really works without > > having the entire data in memory on the server or on the client. > >=20 > > But then I realised that in most use cases, we will not need this binary > > data, so on the client side we will not read from the InputStream of the > > DataHandler. But can that cause any problem? Because when I think about > > it I don't really know how CXF handles this DataHandler. Maybe it > > assumes that the entire content of the DataHandler InputStream will be > > sent, and that it keeps the connection open until the client has > > finished reading, or until some timeout. Or maybe it assumes the > > opposite, that it can close the connection after it has transfered the > > "normal" data, and then open a new connection if the client starts to > > read from the InputStream of the DataHandler. > >=20 > > If it is something like the first scenario, that what can I do to > > transfer this object the right way, without having to read the > > InputStream? I can't find any information about this in the > > documentation. Really, with the way HTTP works, there isn't much you CAN do. The best yo= u=20 can do is grab the input stream and close it immediately. We'll call the= =20 close on the underlying http input stream. What happens then I'm unsure o= f. It COULD do one of two things: 1) Keep reading till the end of the stream anyway so the connection can be = re- used with the Keep-Alive things. 2) Close the underlying socket which would result in a SocketClosed type=20 exception on the server side. This would close the connection entirely so = a=20 future connection would require a new socket and everything to be re-setup. =2D-=20 Daniel Kulp dkulp@apache.org http://dankulp.com/blog