Try to produce simple message via kafka kafka-console-producer.sh
Message:
{"status": "success", "properties": []}
Headers:
HeaderKey1:HeaderValue1
HeaderKey2:HeaderValue2
It’s not clear from the CLI API how this can be done
Source message.txt file:
HeaderKey1:HeaderValue1
HeaderKey2:HeaderValue2
{"status": "success", "properties": []}
cat message.txt | \
docker exec -i kafka kafka-console-producer.sh \
--bootstrap-server localhost:9092 \
--topic test_topic \
--property parse.key=true \
--property key.separator=\n \
--property headers.delimiter=:
Expect that the headers will go into the headers, and the json will go into the value
I think you are missing the
--property parse.headers=truesince the default is false. Also I think you need to rewrite your message like this:And produce with this:
This will work since the defaults are:
headers.key.separator=:andheaders.separator=,