What am I doing wrong? What's the best way to do java string
serialization of protobuf messages?
The native wire format of protocol buffers is just a sequence of
bytes, so it can contain values that are invalid UTF-8 (or any
encoding that has invalid byte sequences). Trying to pack that into
I have created a test Java application that uses ObjectInputStream and
ObjectOutputStream over sockets. No problems, it works! I use my GPB
class writeTo and parseFrom to send and reconstitute my GPB class
using the ObjectInput and Output Streams
But: isn't GPB allowing for
If protocol buffers doesn't use object I/O streams, which streams does
it use? The argument in Java simply asks for an OutputStream
argument, and of course that could mean File, ByteArray, Object, Data,
etc
I mean that it only depends on the methods in OutputStream. You can
provide
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
Anyway, for anyone else wanting to use ByteArrayStream in Java for
writing a Google , here is some code I've used:
ServerSocket serverSocket = new ServerSocket(2004, 10);
Socket socket = serverSocket.accept();
OutputStream outputStream = socket.getOutputStream();
outputStream.flush();
A standard protocol buffer message type ptr_B from which a flat Java
class will be generated does not seem adequat to to so.
Instead some new abstract Class RefMessageT extends Message with a
method T getReferencedObject() would be the solution. ptr_X
messages simply had to be transformed to
An example:
Foo.jar contains the compiled Java code for the following protobuf:
option java_package = com.foo;
message FooMsg {
optional int32 a = 1;
optional int32 b = 2;
...
}
In my code, I want to do this:
option java_package = com.bar;
message BarMsg {
optional
I wish I could pass a builder object to a method and have the method
modify either a value of the builder or a value of a sub-message in
the builder!
I came across this thread, which described exactly the problem I have.
The Car/Engine example in the thread is perfectly illustrative of my
the only workaround that i can think of would be creating a Void
message that is declared as the answer and the rpc implementation to
then ignore those.
like this:
message Void
{
}
service myService
{
rpc OneWayWithoutResponse(FirmwareEvent) returns (Void);
}
is there a way how i
I am confused on how to detect this scenario, and ultimately prevent
such things occurring.
You can't, at least in the simple way. Protocol buffers on the wire
have no type information associated with them, and they're explicitly
designed so that they can accept fields they don't expect to be
I want to serialize the message (id, title and teh text).
Can someone please help me out with this.
You can call yourmessage.toByteArray() (or toByteString()) to get it
as an object, or yourmessage.writeTo(OutputStream) to send it to an
OutputStream.
- Adam
--
You received this message
In the case of repeated strings etc (excluding the enum case), I've been
toying whether something is possible by associating certain objects / values
with unique identifiers on the wire. Potentially this would also allow
graph (rather than tree) serialization.
This is obviously well into the
I don't want to send the whole enchilada on the wire - just the
descriptor for the message being sent.
As I showed above, I know how to get the descriptor on the wire, but
the other side (getting the descriptor off the wire and parsing the
message using it) is unclear to me.
You'll need to
I have a file which i need to encrypt and send so can i use
protocol buffer for this buffer? please do reply me.
Protocol buffers don't provide any built-in encryption or anything
like that, no, all they provide is a serialization format. You could
use protocol buffers to send a file you
I need a generic parser in java, which can de-serialize PB bytes
buffer into a Message or GeneratedMessage. But, GeneratedMessage
provides no such method to merge an arbitary PB bytes and provide an
instance of itself.
From just a message's bytes you can't turn it into a Message. The
Since the client and server are remote, i am not sure how i can send
Descriptor along with message?
All the different kinds of descriptors have associated protocol
messages available through their toProto() methods, so you can
serialize them, send them over the wire, and deserialize them on the
Then my question is this: why to use int32 type even though uint32
uses less bytes covering the same range?
The main reason would be if you ever plan on reading the message from
non-Java code. What you've stated is only true in Java because it has
no unsigned integral types, so protobufs have
I'd like to use dynamically generate/use protocol buffer objects in a
running Java application. This would be running in a production
environment (jre, not jdk) where protoc is not available.
Has anyone written a utility in Java to parse a protocol buffer
definition and dynamically build
18 matches
Mail list logo