[protobuf] Dynamic message schema verification

2022-10-28 Thread Idan Asulin
I'm trying to implement data contract logic. I've 2 services switching messages with each other. Service A send messages in some format + the file descriptor proto of the .proto file used to generate it. Service B gets them both, the message and the file descriptor proto and has to ensure the

Re: [protobuf] Dynamic Message Processing, Java vs. C++

2011-08-27 Thread Jason Hsueh
It appears that the C++ listener code supports multiple types, but assumes that the correct type can be determined by checking if parsing the serialized string returns successfully. This is not a reliable way to detect message types: in fact ParseFromString() only fails if the serialized data is

Re: [protobuf] Dynamic Message Processing, Java vs. C++

2011-08-27 Thread Nader Salehi
If I understand correctly, you are talking about two separate issue. One is that I use of ParseFromString() is unreliable. The other one is that I should switch to self describing messages. The latter is not feasible for now; I receive serialized PB messages that do not contain their type name,

Re: [protobuf] Dynamic Message Processing, Java vs. C++

2011-08-27 Thread Jason Hsueh
No, the issue is one and the same. You cannot receive arbitrary serialized bytes and determine what the message type is. You can do something heuristically, but there is no way for you to be absolutely certain of the message type simply by looking at encoded bytes. Specific points in the code:

Re: [protobuf] Dynamic Message Processing, Java vs. C++

2011-08-27 Thread Nader Salehi
Thanks for looking into the code. Please see my comments inline. On 8/27/2011 17:07 Jason Hsueh writes: No, the issue is one and the same. You cannot receive arbitrary serialized bytes and determine what the message type is. You can do something heuristically, but there is no way for you to

Re: [protobuf] Dynamic Message Processing, Java vs. C++

2011-08-27 Thread Jason Hsueh
On Sat, Aug 27, 2011 at 6:00 PM, Nader Salehi sal...@alumni.usc.edu wrote: Thanks for looking into the code. Please see my comments inline. On 8/27/2011 17:07 Jason Hsueh writes: No, the issue is one and the same. You cannot receive arbitrary serialized bytes and determine what the

Re: [protobuf] Dynamic Message Processing, Java vs. C++

2011-08-27 Thread Jason Hsueh
Sorry, I guess it's not clear if you know the message type or not. But the issue is that you're getting some arbitrary message type out of the transmitted FileDescriptorSet (in fact, any FileDescriptorSet that's ever been received), not the type you want. It's not clear from your code how the C++

[protobuf] Dynamic Message Processing, Java vs. C++

2011-08-26 Thread Nader Salehi
I am having difficulty understanding the problem I am having with parsing of some of the messages that I produce in my test environment. There seems to be some difference between how things are constructed and serialized in Java vs. C++. That is, unless there is a bug in my code :) Here is how I

[protobuf] Dynamic Message

2010-11-05 Thread AdamM
Hello PB Group, I am programming a group of programs in C++ that use PB to communicate. In my first version of the program I was using a .proto file that looked similar to the example 1 below. I would then run a switch statement on a MsgType and create the proper message. I am now starting to

Re: [protobuf] Dynamic Message

2010-11-05 Thread Jon Parise
Hi Adam, I needed to do something similar on a previous project. I stored the serialized version of the type-specific message as opaque data (bytes) in an outer enveloping message. message Envelope { required MsgType type = 1; required bytes data = 2; } Then you can create any type of

Re: [protobuf] Dynamic Message

2010-11-05 Thread Daniel Wright
This is exactly what extensions are for -- see http://code.google.com/apis/protocolbuffers/docs/proto.html#extensions It would look something like: message BaseMessage { required MsgType type = 1; extensions 100 to 10; } Then each module would have a message like: message Msg1 {