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 [email protected] - http://dankulp.com/blog Talend Community Coder - http://coders.talend.com
