【问题标题】:Error when reading events from kafka with SpecificAvroSerde使用 SpecificAvroSerde 从 kafka 读取事件时出错
【发布时间】:2021-10-02 04:47:53
【问题描述】:

从 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));

Error message

但是,当我将事件读取为 GenericRecord 类型而不是 VertexTransactionRawEventValue 时,我能够读取事件。

KStream<String, VertexTransactionRawEventValue> vertexTransactionRawEventValueKStream =
            streamsBuilder.stream(vertexTransactionRawEventTopic);

【问题讨论】:

    标签: java apache-kafka apache-kafka-streams avro


    【解决方案1】:

    错误是说您的类路径中不存在名为 topLevelRecord 的类。

    GenericRecord 不会尝试在您的类路径中查找特定的 Avro 编译类来使用

    【讨论】:

    • 谢谢@OneCricketeer,我用错了serde。
    猜你喜欢
    • 2018-12-27
    • 2021-02-07
    • 2018-11-06
    • 1970-01-01
    • 2016-09-26
    • 2021-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多