【问题标题】:Printing key when consuming JSON messages using kafka-json-schema-console-consumer使用 kafka-json-schema-console-consumer 使用 JSON 消息时打印密钥
【发布时间】:2021-11-25 23:10:48
【问题描述】:

我正在尝试使用 kafka-json-schema-console-consumer 使用 JSON 消息(由 JSON 架构定义),但我没有得到 key解析/打印(但该值确实被打印出来)。

我在任何文档中都找不到属性标志,但我很确定我应该能够打印密钥。我可以确认我正在使用 JSON 模式成功生成消息,并且所有 Kafka 组件(zookeeper、kafka 代理、模式注册表都在工作)

下面是我正在使用的命令。有没有办法打印密钥?

kafka-json-schema-console-consumer \
--bootstrap-server http://kafka:9092 \
--topic source-1 \
--property value.schema='
{
  "definitions" : {
    "record:myrecord" : {
      "type" : "object",
      "required" : [ "timestamp", "data" ],
      "properties" : {
        "timestamp" : {"type" : "string"},
        "data" : {"type" : "string"}
      }
    }
  },
  "$ref" : "#/definitions/record:myrecord"
}' \
--property key.schema='
{
  "definitions" : {
    "record:mykey" : {
      "type" : "object",
      "required" : [ "id" ],
      "additionalProperties" : false,
      "properties" : {
        "id" : {"type" : "integer"}
      }
    }
  },
  "$ref" : "#/definitions/record:mykey"
}'

输出显示值被正确打印,但键没有被打印:

{"timestamp":"10/05/2021 4:41:53 PM","data":"hello world"}

【问题讨论】:

    标签: apache-kafka jsonschema confluent-schema-registry


    【解决方案1】:

    应该是--property print.key=true

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-06-06
      • 2020-06-17
      • 2021-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多