I'm a newcomer to protobuf and am trying to wrap my head around some
things. Let's say I have a message receiver of some kind. It can
receive different types requests. All messages are encoded in protobuf
and my receiver has all *.proto message definitions necessary be able
to decode all incoming requests.

My question is, does protobuf come with any bells and whistles that
let me decode a random incoming message, given all possible message
definitions? If not, how do you generally cope with this situation?
Because I feel it's a common one.

I guess one possible solution is to create another message definition:
message GenericMessage {
  enum MessageType {
    SET_NAME = 0;
  required MessageType type = 0;
  required bytes protobuf_data = 1;

However, this would require me to do two deserializations. Is this the
prefered way to go? I'm curious to hear you input. Please pinpoint me
if this has been answered previously in forum or in the documentation.


You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to