Streaming Dynamic Messages

37 views
Skip to first unread message

Dan

unread,
Nov 9, 2009, 8:25:37 PM11/9/09
to Protocol Buffers
Im trying to write the following client/server exchange using the Java
Protobuf API:

1) Client makes a request to the server
2) Server creates a series of Messages all of the same type to stream
back to the client. The type of the messages will be different
depending on the parameters of the client's request.
3) The Server streams the messages back to the client in the following
format:

<Descriptor Size>
<MessageDescriptor (as a DescriptorProto message)>
<Message Size>
<Message>
<Message Size>
<Message>
...

4) (This is where I'm stuck) The client makes a csv file from the
results by reading the field names from the DescriptorProto to use for
the header and iterates through the fields of each message to write
the records. It looks like DynamicMessage should give me what I need
but I can't figure out how to convert the DescriptorProto object to
the Descriptor object.

Note: I know this approach of sending just the DescriptorProto for the
messages cannot possibly work if the message has any fields that are
of a Message Type that are not nested but for my use case I know that
fields of the messages returned will always be a primative type. Even
using the approach described in the techniques section of the wiki of
sending an entire FileDescriptorSet I still have the same problem of
converting the Proto objects to the proper framework objects. I've
seen in previous posts how to do this using the C++ API but not the
Java Implementation.

Kenton Varda

unread,
Nov 9, 2009, 8:37:16 PM11/9/09
to Dan, Protocol Buffers
You want:  com.google.protobuf.Descriptors.FileDescriptor.buildFrom()

Dan

unread,
Nov 10, 2009, 8:22:17 PM11/10/09
to Protocol Buffers
Yes! That works, thanks.
> > Java Implementation.- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages