Kafka connect-无法将字符串强制转换为struct [英] Kafka connect - string cannot be casted to struct
问题描述
我正在做融合的kafka connect 5.2.3版本的poc.我们正在尝试将主题文件的消息复制为备份,并在需要时从该文件复制回主题.
I am doing poc of confluent kafka connect version 5.2.3. We are trying to copy message of topic a file as backup and from this file back to topic when we need it.
主题有 键=字符串 值= protbuf
Topic has Key =string Value=protbuf
我正在使用
key.convertor=org.apache.kafka.connect.storgare.StringConvertor
value.convertor=com.blueapron.connect.protobuf.ProtobufConvertor
value.convertor.protoClassName=<proto class name>
key.convertor=org.apache.kafka.connect.storgare.StringConvertor
value.convertor=com.blueapron.connect.protobuf.ProtobufConvertor
value.convertor.protoClassName=<proto class name>
接收器配置
name=test
connector.class=FileStreamSink
tasks.max=1
file=test.txt
topics=testtopic
源配置
name=test
connector.class=FileStreamSource
tasks.max=1
file=test.txt
topics=testtopic_connect
我能够将其成功下沉到具有以下文件内容的文件中
I am able successfully sink it to a file with file content as below
Struct{<message in name value pair>}
Struct{<message in name value pair>}
....
我使用相同的文件将其返回给另一个主题.当我运行源代码时,它会引发错误
The same file i use to source it back to a different topic. When i run the source it throw error
不能将字符串强制转换为org.apache.kafka.connect.data.Struct.
String cannot be casted to org.apache.kafka.connect.data.Struct.
问题是
- 当我的kafka主题具有键值对时,为什么在文件中看不到任何键.
- 为什么源无法将内容从文件复制到主题并引发与投射相关的错误.
- 当我使用kafka提供的ByteArrayConvertor时,出现类似的错误.字符串不能转换为字节.理想情况下,ByteArrayConvertor应该适用于任何类型的数据.
- blueapron仅适用于protobuf3版本吗?
推荐答案
blueapron仅适用于protobuf3版本吗?
Does blueapron only works with protobuf3 version?
是的,因为我们仅在内部使用proto3(我们需要Python,Java和Ruby代码生成-Ruby仅适用于proto3),所以不幸的是,当我们首次构建此工具时,并没有建立对proto2定义的支持.我已经更新了项目自述文件以反映这一点( https://github.com/blueapron/kafka-connect-protobuf-converter#compatibility ).
Yes, since we only use proto3 internally (we needed Python, Java and Ruby code generation - Ruby is only available for proto3), unfortunately we didn't build in support for proto2 definitions when first building this tool. I've updated the project readme to reflect that (https://github.com/blueapron/kafka-connect-protobuf-converter#compatibility).
这篇关于Kafka connect-无法将字符串强制转换为struct的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!