【问题标题】:Kafka console consumer to read avro messages in HDP 3Kafka 控制台消费者在 HDP 3 中读取 avro 消息
【发布时间】:2020-07-14 14:51:00
【问题描述】:

尝试使用来自控制台消费者的 kafka Avro 消息,但不确定如何反序列化消息。

sh /usr/hdp/current/kafka-broker/bin/kafka-console-consumer.sh --bootstrap-server localhost:6667 --topic test --consumer.config /home/user/kafka.consumer.properties --from-beginning --value-deserializer ByteArrayDeserializer

Schema Registry 中测试主题的 Avro Schema 是:

{
 "type": "record",
 "namespace": "test",
 "name": "TestRecord",
 "fields": [
  {
   "name": "Name",
   "type": "string",
   "default": "null"
  },
  {
   "name": "Age",
   "type": "int",
   "default": -1
  }
 ]
}

使用 HDP 3.1 版本和 Kafka-clients-2.0.0.3.1.0.0-78

有人可以帮我从控制台读取 Avro 消息所需的反序列化器。

【问题讨论】:

    标签: apache-kafka kafka-consumer-api cloudera hdp


    【解决方案1】:

    使用kafka-avro-console-consumer

    例如

    sh /usr/hdp/current/kafka-broker/bin/kafka-avro-console-consumer.sh \
    --bootstrap-server localhost:6667 \
    --topic test \
    --from-beginning \
    --property schema.registry.url=http://localhost:8081
    

    【讨论】:

    • 不幸的是我在 bin 文件夹中没有这样的脚本。
    • 尝试使用find /usr/hdp/current/ -name kafka-avro-console-consumer.sh定位它
    • 我已经尝试过了,但我没有看到这样的脚本可用。我可以从公共下载吗?
    • 它对基于 HDP 的 Kafka 发行版如何工作,我认为 Avro 消费者适用于融合?因为在我从公共复制 bash 后,它因缺少 schema-registry-run-class 而失败。
    • 好点。在这种情况下,请前往confluent.io/download :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-09
    • 2017-11-10
    • 2018-07-01
    • 1970-01-01
    • 2019-09-24
    • 2016-01-15
    相关资源
    最近更新 更多