【问题标题】:How to produce avro format data onto topic in kstreams如何在 kstreams 中将 avro 格式的数据生成到主题上
【发布时间】:2018-06-11 18:53:33
【问题描述】:
KStream<String, String> left = builder.stream("source1");

left.toStream("soure2")

想在发送到source2之前进行序列化

【问题讨论】:

    标签: java apache-kafka avro apache-kafka-streams confluent-schema-registry


    【解决方案1】:
    GenericRecord genericRecord2 = new GenericData.Record(schema);
    

    使用 GenericRecord obj 获取 schema,然后将 key、value 放入`

    genericRecord2.put(k, v);
    

    完成 put 操作后,使用 kstream api 的 .to() 方法将其写入主题

    .to("topic",Produced.with(stringSerde, genericAvroSerde));`
    

    确保在模式注册表中注册 avro 模式

    【讨论】:

    • 你总是可以使用kstreamRef.print();打印kstream值
    猜你喜欢
    • 2018-11-06
    • 2019-07-30
    • 2022-08-04
    • 2019-08-05
    • 2020-09-05
    • 1970-01-01
    • 1970-01-01
    • 2019-09-10
    • 2018-11-11
    相关资源
    最近更新 更多