apache-kafkakcat

How to turn a kafkacat payload printout into binary


I can use kafkacat to get a tuple from a topic and print it out:

kafkacat -b kafka10.myorg.com:9092 -t MyTopic -o -1 -f '%s\n'

And I get something like this in my terminal:

�ǐے�ғ�����������ǐے�ғ���������S1_153314S3_153314S4_5422973S2_5420991...

Is it possible for me to convert the printed out payload to binary format so I can feed that to my local code to debug?


Solution

  • You can consume the messages directly as binary data without applying formatting.

    kafkacat -b kafka10-staging.salesforceiq.com:9092 -t MyTopic -o -1 -D "" > out.file
    

    The usage of -D "" is there to avoid adding the "\n" to the binary data. https://github.com/edenhill/kafkacat/issues/72