Unbuffered CXF (No content-length header)

Viewed 667

I recently switched from using Jersey to CXF for a JAX-RS application. I was also using StreamingOutput to output my own stream, as the data contained in the stream takes ~20s to create, and can be partially processed by clients. This was all working fine with Jersey, but I've now switched to returning JAXB beans with CXF and can't get the streaming behaviour. With Jersey, I had to set jersey.config.contentLength.buffer.server to 0 and flush the OutputStream to get the data to the client, but I can't find the equivalent with CXF. I've tried writing an Interceptor based on the StreamInterceptor example, but the write method of the Message's OutputStream doesn't get called until all processing has finished. The JAXB bean contains a Collection with a custom Iterator that supplies data when it's available. I can see the data getting buffered in the debugger.

How can I stream JAXB beans with CXF?

1 Answers
Related