I just started looking into protobuf for a project of mine.
>From the Java Api page I could not really find how to parse a
generated (compiled .proto is present) but "unknown" message.

So for example: I have messages types MessageA and MessageB. The
client component receives some bytes representing a message of type A
OR B. Do I have to add information of the type of message that's been
send, or is there an easy way of automatically parsing the message

byte[] b; //hols byte representation of message
Message message = foo(b); //parse message
if(message instanceof MessageA)
  System.out.println("was type A");
  System.out.println("was type B");

Thank you in advance,


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

Reply via email to