I am posting protobuf messages to a message broker, and in order to 
identify them, I prefix the message bytes with the serialized result of a 
"header" message:

message Header {
   int version = 1;
   string message_type = 2;
}

It is easy, to concatenate the header+actual message bytes and post the 
resulting block to a queue. But how do I take these apart on the receiving 
end? Suppose I get a byte-buffer consisting of:

---------------
| header      |
---------------
| body        |
---------------

Is it OK to throw this oversized buffer at the Header deserialization?  
Will the extra bytes hurt anything?

Then, once I extract the Header message, how do I know where the body 
begins? I could turn around and ask the Header object "how big would you be 
if serialized?".  Is that reliable?  Is there a better way?

Thanks
john

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to