Re: [protobuf] Generic Message Dispatch and Message Handler
On Oct 26, 2010, at 15:45 , maninder batth wrote: My generic Handler would create a GeneratedMessage and look for the field messageType. Based on the value of the messageType, a particular handler will be invoked. This is basically what I have done, for my protobuf RPC implementation. If you only need to choose between a limited set of types, you may want a union type or extensions instead: http://code.google.com/apis/protocolbuffers/docs/techniques.html#union http://code.google.com/apis/protocolbuffers/docs/proto.html#extensions Evan -- Evan Jones http://evanjones.ca/ -- 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 protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
[protobuf] Re: Generic Message Dispatch and Message Handler
Evan, How are you parsing arbitrary PB bytes into a Generated Message ? I am finding no class in API that can deserialize PB byte buffer into GeneratedMessage? On Oct 27, 6:27 am, Evan Jones ev...@mit.edu wrote: On Oct 26, 2010, at 15:45 , maninder batth wrote: My generic Handler would create a GeneratedMessage and look for the field messageType. Based on the value of the messageType, a particular handler will be invoked. This is basically what I have done, for my protobuf RPC implementation. If you only need to choose between a limited set of types, you may want a union type or extensions instead: http://code.google.com/apis/protocolbuffers/docs/techniques.html#union http://code.google.com/apis/protocolbuffers/docs/proto.html#extensions Evan -- Evan Joneshttp://evanjones.ca/ -- 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 protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
[protobuf] Parse PB bytes into a generic message
Hello, 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. Any leads would be greatly appreciated. -- 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 protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
Re: [protobuf] Parse PB bytes into a generic message
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 serialized format doesn't include type information. You've got a couple choices. First, if you can send the message's Descriptor along with the message, then you can use DynamicMessage.parseFrom(Descriptor, byte[]) to deserialize it. If you can't send the message's Descriptor along, then you can use UnknownFieldSet.parseFrom(byte[]), but that's not going to give you very much at all, just tag numbers, their wiretype, and their value. - Adam -- 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 protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
Re: [protobuf] New Ruby Protocol Buffers library
I think just the github page for the project would be great. Thanks! http://github.com/mozy/ruby-protocol-buffers -- Brian On Oct 26, 2010, at 10:56 PM, Kenton Varda wrote: I'd like to add this to the third-party wiki, but I'm not sure which link to use. Can you suggest (or create) a general-purpose landing page? On Thu, Oct 21, 2010 at 10:02 AM, Brian Palmer br...@codekitchen.net wrote: Mozy has just open sourced their implementation of Protocol Buffers for Ruby. The implementation has been in use internally at Mozy for over a year. This implementation has put a lot of focus on serialization/deserialization performance, and completeness. The ruby protobuf compiler calls out to protoc to do the heavy lifting, so it's using the same parser as the official compiler. It looks like now there's a plugin system for protoc itself, so if we were writing this project today we probably would've just made the compile-to-ruby functionality a plugin. Enjoy! The repo: http://github.com/mozy/ruby-protocol-buffers The gem: https://rubygems.org/gems/ruby-protocol-buffers The docs: http://rubydoc.info/gems/ruby-protocol-buffers/0.8.4/frames -- Brian Palmer -- 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 protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en. -- 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 protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
[protobuf] Serialize message in C++, parse using Java
I've Google for a day now and could not find full information on the following problem. I want to serialize protobuf messages in C++, send them to a JMS (using activemq-cpp API) and parse in my Java server. Based on what I found in my searches, here's my C++ function that serializes the message: /* * Serialize given protobuf message and send to Active MQ JMS using the producer. */ void MessageProducer::send( const diva::messaging::Message proto_mesg ) { using namespace google::protobuf::io; long bufLength = proto_mesg.ByteSize() + CodedOutputStream::VarintSize32( proto_mesg.ByteSize() ); unsigned char buf[bufLength]; ZeroCopyOutputStream* raw_output = new ArrayOutputStream( buf, bufLength ); CodedOutputStream* coded_output = new CodedOutputStream(raw_output); // Prepend the message size to wire message. coded_output-WriteVarint32( proto_mesg.ByteSize() ); proto_mesg.SerializeToCodedStream(coded_output); // Create an ACtive JMS message and insert task module information in header. cms::BytesMessage* message = m_session-createBytesMessage(); // Write serialized protobuf message to the JMS message and send. message-writeBytes( buf, 0, bufLength ); m_producer-send( message ); delete message; delete coded_output; delete raw_output; } And here's the part in Java that parses teh received messages from JMS: // Create a byte array for received message. BytesMessage receivedMessage = (BytesMessage)received_message; logger.info(received message in NAC); byte[] mesg_bytes = new byte[(int)receivedMessage.getBodyLength()]; int num_read = receivedMessage.readBytes(mesg_bytes); if ( num_read != receivedMessage.getBodyLength() ) { throw new Exception(Error reading message into byte array); } // Create registry for all possible DIVA messages. ExtensionRegistry er = ExtensionRegistry.newInstance(); DivaBase.registerAllExtensions(er); // Parse the received message. diva.messaging.DivaBase.Message m = diva.messaging.DivaBase.Message.parseFrom( mesg_bytes, er ); Currently, I get Problem parsing message received in NAC: com.google.protobuf.InvalidProtocolBufferException: Protocol message end-group tag did not match expected tag. Problem parsing message received in NAC: java.lang.ClassCastException: org.apache.activemq.command.ActiveMQTextMessage cannot be cast to javax.jms.BytesMessage errors for each message and cannot see what I'm doing wrong. Thanks for any comments on the code and/or pointers you might provide. -- 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 protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
[protobuf] Issue 230 in protobuf: Documentation of the import behavior
Status: New Owner: ken...@google.com Labels: Type-Defect Priority-Medium New issue 230 by sanchom: Documentation of the import behavior http://code.google.com/p/protobuf/issues/detail?id=230 As discussed at http://groups.google.ca/group/protobuf/browse_thread/thread/a72c9b4d8e3bdff5, the documentation of the import statement in the language guide doesn't really explain how it interacts with the --proto_path. From the language guide, it's not obvious that --proto_path should point at the root and that all imports should be fully qualified. -- 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 protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
[protobuf] Re: Parse PB bytes into a generic message
Since the client and server are remote, i am not sure how i can send Descriptor along with message? On Oct 27, 1:14 pm, Adam Vartanian flo...@google.com wrote: 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 serialized format doesn't include type information. You've got a couple choices. First, if you can send the message's Descriptor along with the message, then you can use DynamicMessage.parseFrom(Descriptor, byte[]) to deserialize it. If you can't send the message's Descriptor along, then you can use UnknownFieldSet.parseFrom(byte[]), but that's not going to give you very much at all, just tag numbers, their wiretype, and their value. - Adam -- 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 protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
Re: [protobuf] Re: Parse PB bytes into a generic message
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 other end. You have to deserialize a FileDescriptorProto, though, so you can either send the appropriate FileDescriptorProto or just send a DescriptorProto and build the file on the receiving end. - Adam -- 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 protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
Re: [protobuf] Re: Generic Message Dispatch and Message Handler
On Oct 27, 2010, at 11:36 , Jimm wrote: How are you parsing arbitrary PB bytes into a Generated Message ? I am finding no class in API that can deserialize PB byte buffer into GeneratedMessage? I'm using the generic Service API that is included with protocol buffers, so I'm not using GeneratedMessage. Rather, I'm using a message instance itself. The register does something ilke this: serviceRegister.registerCall(MyCustomMessage.getDefaultInstance()); Then you can parse this with code like the following: Message requestPrototype = ...; // stored in registerCall implementation Message.Builder builder = requestPrototype.newBuilderForType(); builder.mergeFrom(requestByteString); My code is actually available in the following hg repository. I don't recommend that people use it directly, since it is a bit hacky, but it could serve as an example: http://people.csail.mit.edu/evanj/hg/index.cgi/javatxn/file/tip/src/ca/evanjones/protorpc/ServiceRegistry.java http://people.csail.mit.edu/evanj/hg/index.cgi/javatxn/file/tip/src/ca/evanjones/protorpc/ProtoMethodInvoker.java Good luck, Evan -- Evan Jones http://evanjones.ca/ -- 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 protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
[protobuf] Migration from 2.0.3 to 2.3.0 problem on Mac OS –arch ppc
Hi, I would like to migrate from 2.0.3 to 2.3.0. Everything looks ok except that I can’t link my existing projects on Mac OS with gcc 4.0 – arch ppc (only, i386 works fine). I receive: Undefined symbols: ___floatundidf, referenced from: google::protobuf::DescriptorBuilder::OptionInterpreter::SetOptionValue(google::protobuf::FieldDescriptor const*, google::protobuf::UnknownFieldSet*)in libprotobuf.a(descriptor.o) google::protobuf::TextFormat::Parser::ParserImpl::ConsumeDouble(double*)in libprotobuf.a(text_format.o) ___floatundisf, referenced from: google::protobuf::DescriptorBuilder::OptionInterpreter::SetOptionValue(google::protobuf::FieldDescriptor const*, google::protobuf::UnknownFieldSet*)in libprotobuf.a(descriptor.o) ld: symbol(s) not found It looks like this code in SetOptionValue isn’t changed from 2.0.3. What is then? Any ideas? Thanks, -i -- 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 protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.