6

I need to produce batch messages to Kafka so I have a file that I feed kafkacat:

kafkacat -b localhost:9092 -t <my_topic> -T -P -l /tmp/msgs

The content of /tmp/msgs is as follows

-H "id=1"
{"key" : "value0"}
-H "id=2"
{"key" : "value1"}

When I run the kafkacat command above, it inserts four messages to kafka - one message per line in /tmp/msgs.

I need to instruct kafkacat to parse the file correctly - that is -H "id=1" is the header for the message {"key" = "value0"}.

How do I achieve this?

Thanks

Jenia Ivanov
  • 2,485
  • 3
  • 41
  • 69

1 Answers1

0

You need to pass the headers as follows.

kcat -b localhost:9092 -t topic-name -P -H key1=value1 -H key2=value2 /temp/payload.json
curious_cat
  • 886
  • 2
  • 11
  • 14