我正在尝试使用kafka-json-schema-console-consumer使用 JSON 消息(由 JSON Schema 定义) ,但我没有得到要解析/打印的密钥(但该值确实被打印出来)。
我在任何文档中都找不到属性标志,但我很确定我应该能够打印密钥。我可以确认我正在使用 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"}