blueapron / kafka-connect-protobuf-converter

Protobuf converter plugin for Kafka Connect
Other
94 stars 53 forks source link

Proto class is not a valid proto3 message class #44

Open iguenkinrl opened 4 years ago

iguenkinrl commented 4 years ago

Hello,

I've installed protobuf convertor and build my own protobuf definition jar. I've put it into ../confluent/share/java/kafka-serde-tools/ directory in my connector definition I set up "value.converter.protoClassName":"com.rl.messaging.messages.BusinessEventMessages$BusinessEvent" when I'm starting connector I've got the following error message ERROR Failed to start task rabbitMQ-src-0 (org.apache.kafka.connect.runtime.Worker:473) org.apache.kafka.connect.errors.ConnectException: Proto class com.rl.messaging.messages.BusinessEventMessages$BusinessEvent is not a valid proto3 message class in ProtobufConverter.java code I found the following entry String protoClassNameString = protoClassName.toString(); try { protobufData = new ProtobufData(Class.forName(protoClassNameString).asSubclass(com.google.protobuf.GeneratedMessageV3.class), legacyNameString); } catch (ClassNotFoundException e) { throw new ConnectException("Proto class " + protoClassNameString + " not found in the classpath"); } catch (ClassCastException e) { throw new ConnectException("Proto class " + protoClassNameString + " is not a valid proto3 message class"); } that means that my own protobuf should be a subclass of com.google.protobuf.GeneratedMessageV3.class

How should I build my own protobuf jar to solve this error ?

BusinessEventMessages.proto.zip

bagipriyank commented 4 years ago

Change the first line in BusinessEventMessages.proto from syntax = "proto2"; to syntax = "proto3";. That tells protoc to compile a generated class for proto3. Please note that there are some differences in proto2 v/s proto3. There is no optional keyword as every field is optional by default - among some other differences. But I mentioned optional specifically since you are using it with in your messages.

fhajiyev commented 1 year ago

@bagipriyank Hello, I'm facing this issue at the moment. Does blueapron only support proto3? Our proto needs to be proto2 due to certain restrictions. Is there a configuration for specifying the type of proto? Thanks!