users@jersey.java.net

[Jersey] ChunkedParser query

From: <michael.lewis_at_barclays.com>
Date: Thu, 17 Jul 2014 15:34:19 +0100

Hi,

I have MessageBodyReader and MessageBodyWriter classes that can handle Protobuf message types.
I then wanted to use ChunkedOutput so that I could send a set of Protobuf objects to a client (a long running process that
periodically sends back intermediate results).

I changed my writer and reader to write/read the message length prior to the message itself.

One issue I have is with ChunkedParser - the first time it is invoked, my 'readChunk' method can:

1) read the length of the message (int - 4 bytes)

2) the message Itself into a byte array

I can return a byte array (containing both) so that 'readChunk' passes my MessageBodyReader the correct

number of bytes.



This works fine for the first message, but I do now know what byte delimiter to use as the ChunkedOutput delimiter can't be null.

I can't use string like \r\n as these may be contained within the protobuf message binary in theory.

Has anyone any ideas or done something similar?



Regards,

Mike



_______________________________________________

This message is for information purposes only, it is not a recommendation, advice, offer or solicitation to buy or sell a product or service nor an official confirmation of any transaction. It is directed at persons who are professionals and is not intended for retail customer use. Intended for recipient only. This message is subject to the terms at: www.barclays.com/emaildisclaimer.

For important disclosures, please see: www.barclays.com/salesandtradingdisclaimer regarding market commentary from Barclays Sales and/or Trading, who are active market participants; and in respect of Barclays Research, including disclosures relating to specific issuers, please see http://publicresearch.barclays.com.

_______________________________________________