In Java, the package name is used as the Java package unless you have explicitly specified a javapackage, as we have here. Even if you do provide a javapackage, you should still define a normal package as well to avoid name collisions in the Protocol Buffers name space as well as in non-Java languages. Even if you do provide a javapackage, you should still define a normal package as well to avoid name collisions in the Protocol Buffers name space as well as in non-Java languages. After the package declaration, you can see two options that are Java-specific: javapackage and javaouterclassname.
Active1 year, 4 months ago
I am receiving protobuf messages on kafka, the consumer is configured to deserialize the events using
If I use
parseFrom(byte[] data)
method of com.google.protobuf.Parser
by passing byte array of the deserialized event string, the method throws following exception: Putlocker movie gravity.If I instead deserialize kafka events with
and directly pass the byte array thus received to
parseFrom
, protobuf is correctly parsed without any exception.Why does the second way work, but the first does not?
Java Protobuf To Json
user87407
Java Protobuf Serialize Deserialize
user87407user8740731511 gold badge44 silver badges1616 bronze badges
1 Answer
You are using a String deserializer, which expects certain special characters to define the message's limits. It tries to deserialize a STRING but he receives just a bunch of bytes with a format the consumer doesn't expect at all.
There are a few scratches and scuffs none interfere with functionality. I have installed a brand new 128Gb SSD, battery and charger.
Windows 10 was freshly installed and licensed with the bios COA.
You have a producer which serializes with
ByteArraySerializer
, so your consumer must deserialize it with a ByteArrayDeserializer
.Try producing with a
aranorg.apache.kafka.common.serialization.StringSerializer
if you really want to automatically deserialize in String format.Java Protobuf Serialize To File
aran2,92722 gold badges2020 silver badges4949 bronze badges