apache-kafka - 使用 kafka-json-schema-console-consumer 使用 JSON 消息时打印密钥
问题描述
我正在尝试使用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"}
解决方案
它应该是--property print.key=true
推荐阅读
- python - 哪个winsorize更准确,Python还是R
- java - 为什么我不能显示我的arrayList,当我用另一个线程保存她时?
- node.js - 你将如何加密/解密 Node.js 中的数字?
- apache-kafka - 卡夫卡消费者离开消费者组
- javascript - 类方法中的 Javascript 变量不会持久化
- report - 应该选择 Google Ad Manager 帐户的哪些维度和指标?
- javascript - 从多个参数中查找重复项
- c# - 在多行上按正则表达式拆分
- azure - Azure 存储不认为我的 iot-hub 是受信任的服务?
- ios - Swift App Termination 移除 Kingfisher 磁盘缓存