Mustafa Sezgin wrote:
Hi all,
Just a quick question about handling multi part msgs. We are writing a
number of Rest services using CXF + Spring. Some of these services will
need to accept files, some of which are quite large. We deal with lots of
data from lots of users.
I am wondering what the best way to do this is. Currently, as an argument
to the service method, we specify a MultipartBody object, thus we will be
requesting users of our services send these files in multi part msgs where
each file is a single part within the multi part msg. However I have my
doubts about this. How does CXF handle large files? Say if someone sends
3x2GB files? From what I can see, the service does not actually get passed
the multi part msg until the msg has been received in full. Thus the data
received (in total 6GB) will need to be stored somewhere, before being
passed to the service. Will this be written to disk, and if so, is this
configurable in anyway? I am presuming CXF doesn't store all this data in
memory, as this would seem like the wrong way to do this...
If there are 'better' ways to do this with CXF, I would love to hear
them..
You can use MTOM, there is a system property
"org.apache.cxf.io.CachedOutputStream.Threshold" that you can set, by
default its value is 64kb, any attachment more than that is saved in a
temp file, you can also configure this temp file directory by another
system property "org.apache.cxf.io.CachedOutputStream.OutputDirectory".
Also, you require to increase your web container's socket timeout time,
as the send and receive operations will take some time. You can use this
with JAX-WS, but I am not sure about JAX-RS.
You can otherwise you can build RESTful endpoints through JAX-WS
provider interface, where you can use StreamSource.
I tried but may be someone on list can give throw more light on 'better'
ways. :)
With Regards,
Mayank
You can use MTOM for end
Thanks in advance for the responses..
Mustafa