I am trying to consume JSON messages (defined by a JSON Schema) using kafka-json-schema-console-consumer and I am not getting the key to be parsed/printed (but the value does get printed out) .
I could not find the property flags in any documentation but I am pretty sure I should be able to print the key. I can confirm that I am producing messages successfully with a JSON schema and that all Kafka components (zookeeper, kafka broker, schema registry are working)
Below is the command I am using. Is there a way to have the key be printed?
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"
}'
The output shows that the value is being printed properly but the key is not being printed:
{"timestamp":"10/05/2021 4:41:53 PM","data":"hello world"}
It should be --property print.key=true