users@jersey.java.net

[Jersey] Re: Jersey xml streaming

From: Martin Matula <martin.matula_at_oracle.com>
Date: Fri, 15 Jun 2012 21:59:41 +0200

On Jun 15, 2012, at 9:22 AM, Michael Cherkasov wrote:

> Hi all,
>
> As response service must produce huge XML answer. I use JAXB for this. I want to clarify,
> does jersey serialize all object( and store XML in memory ) before send answer or jersey do streaming?

Jersey doesn't store the output in memory - it passes the response output stream to the JAXB marshaller and lets it do it's job.

>
> Also I what to try different solutions for serializations like XStream, google-gson, Json-Smart,
> jackson and other, I need to find the fastest one. So how implement streaming data with jersey?
>
> I found this one http://neopatel.blogspot.com/2011/04/jersey-streaming-binary-data.html
> but in this case you produce stream from which jersey read data, but I need to get stream
> to which I can write answer, does it possible?

Sure - you can write your own MessageBodyWriter - it receives the response output stream from Jersey runtime and writes to it.
Martin