java - 使用 SpecificAvroSerde 从 kafka 读取事件时出错
问题描述
从 kafka 主题读取事件时出错
'org.apache.kafka.common.errors.SerializationException:为 id 4494 反序列化 Avro 消息时出错原因:org.apache.kafka.common.errors.SerializationException:在查找阅读器架构时找不到写入器架构中指定的类 topLevelRecord特定记录。
final Map<String, String> schemaMap = Collections.singletonMap(AbstractKafkaAvroSerDeConfig.SCHEMA_REGISTRY_URL_CONFIG, schemaServerURL);
final SpecificAvroSerde<VertexTransactionRawEventValue> vertexTransactionRawEventValueAvroSerde = new SpecificAvroSerde<>();
vertexTransactionRawEventValueAvroSerde.configure(schemaMap, false);
KStream<String, VertexTransactionRawEventValue> vertexTransactionRawEventValueKStream =
streamsBuilder.stream(vertexTransactionRawEventTopic,Consumed.with(Serdes.String(), vertexTransactionRawEventValueAvroSerde));
但是,当我将事件读取为 GenericRecord 类型而不是 VertexTransactionRawEventValue 时,我能够读取事件。
KStream<String, VertexTransactionRawEventValue> vertexTransactionRawEventValueKStream =
streamsBuilder.stream(vertexTransactionRawEventTopic);
解决方案
错误是说topLevelRecord
您的类路径中不存在名为的类。
GenericRecord 不会尝试在您的类路径上查找特定的 Avro 编译类以使用
推荐阅读
- react-native - 无法在 Android 上获取博览会推送令牌
- d3.js - 传单地图上的矩形箱
- c - 用 [0x...] 声明的字符数组
- apache-spark - Spark 结构化流式多动作共享相同的检查点
- database - 我在新安装的 GridDB 实例上遇到凭据错误。我已经更改了密码,但它并没有改变任何东西
- puppet - 木偶 - 找不到课程
- javascript - JavaScript 比较对象原型并将它们相加
- mediawiki - 是否可以使用访问代码限制使用 MediaWiki 创建帐户?
- c++ - 如何将 std::pair 声明为朋友,以便看到私有默认 ctor
- mysql - 选择:汇总值和按日期分组