You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by SureshG <sg...@gmail.com> on 2011/12/12 18:27:10 UTC

Large response (400MB) options

Hi,
We have a requirement to send a large response (400MB) with out attachments.
In one of the responses in the forum, I have read that there will be a
memory issue as the whole meesge will be in the memory. I am currently using
CXF 2.2.9.  what are my options in dealing with the large responses? Are
there any better options available if I upgrade the CXF to the latest
version?

Thanks for your help

Suresh

--
View this message in context: http://cxf.547215.n5.nabble.com/Large-response-400MB-options-tp5069008p5069008.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Large response (400MB) options

Posted by Christian Schneider <ch...@die-schneider.net>.
Hi Suresh,

typically you will not want to send 400 MB xml. If it is ok to send it 
as a MTOM attachment it is quite easy to not have the message in memory.
See: http://cxf.apache.org/docs/mtom-attachments-with-jaxb.html

So in this case you have a DataHandler as API and can e.g. directly 
stream a file to it.

Christian


Am 12.12.2011 18:27, schrieb SureshG:
> Hi,
> We have a requirement to send a large response (400MB) with out attachments.
> In one of the responses in the forum, I have read that there will be a
> memory issue as the whole meesge will be in the memory. I am currently using
> CXF 2.2.9.  what are my options in dealing with the large responses? Are
> there any better options available if I upgrade the CXF to the latest
> version?
>
> Thanks for your help
>
> Suresh
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Large-response-400MB-options-tp5069008p5069008.html
> Sent from the cxf-user mailing list archive at Nabble.com.


-- 

Christian Schneider
http://www.liquid-reality.de

Open Source Architect
Talend Application Integration Division http://www.talend.com


Re: Large response (400MB) options

Posted by Daniel Kulp <dk...@apache.org>.
On Monday, December 12, 2011 9:27:10 AM SureshG wrote:
> Hi,
> We have a requirement to send a large response (400MB) with out attachments.
> In one of the responses in the forum, I have read that there will be a
> memory issue as the whole meesge will be in the memory. I am currently
> using CXF 2.2.9.  what are my options in dealing with the large responses?
> Are there any better options available if I upgrade the CXF to the latest
> version?

Well, it really depends on what you are planning to do with the messages, how 
it is generated, etc....     In general, CXF really goes out of its way to try 
and NOT keep entire messages in memory whenever possible.  However, there are 
situations in which it's unavoidable.  For example, the WS-Security library we 
use (wss4j) requires a full DOM.    JAX-WS Handlers require a full DOM.   
etc....

Depending on how the message is created, there are several options for you.   
If you want to deal with it at the XML level, you can can use a 
Provider<Source> type thing and return a SAX source or StaxSource that 
generate the proper events based on whatever you runtime does in a streaming 
fassion.  When CXF is ready to write them out, it will call the appropriate 
methods and the events would get streamed right out.

If you want to use JAXB, it's IS possible, but becomes a bit trickier.   For 
things like collections in the objects, you can use a List object that doesn't 
really wrap the data, but instead creates an iterator that would generate the 
data objects on demand.   Likewise for getter methods and such.

-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com