HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

kcat — Apache Kafka producer and consumer tool. More information: <https://manned.org/kcat>.

Submitted by: @import:tldr-pages··
0
Viewed 0 times
commandandkafkacliapacheproducerconsumerkcat

Problem

How to use the kcat command: Apache Kafka producer and consumer tool. More information: <https://manned.org/kcat>.

Solution

kcat — Apache Kafka producer and consumer tool. More information: <https://manned.org/kcat>.

Consume messages starting with the newest offset:
kcat -C -t {{topic}} -b {{brokers}}


Consume messages starting with the oldest offset and exit after the last message is received:
kcat -C -t {{topic}} -b {{brokers}} -o beginning -e


Consume messages as a Kafka consumer group:
kcat -G {{group_id}} {{topic}} -b {{brokers}}


Publish message by reading from stdin:
echo {{message}} | kcat -P -t {{topic}} -b {{brokers}}


Publish messages by reading from a file:
kcat -P -t {{topic}} -b {{brokers}} {{path/to/file}}


List metadata for all topics and brokers:
kcat -L -b {{brokers}}


List metadata for a specific topic:
kcat -L -t {{topic}} -b {{brokers}}


Get offset for a topic/partition for a specific point in time:
kcat -Q -t {{topic}}:{{partition}}:{{unix_timestamp}} -b {{brokers}}

Code Snippets

Consume messages starting with the newest offset

kcat -C -t {{topic}} -b {{brokers}}

Consume messages starting with the oldest offset and exit after the last message is received

kcat -C -t {{topic}} -b {{brokers}} -o beginning -e

Consume messages as a Kafka consumer group

kcat -G {{group_id}} {{topic}} -b {{brokers}}

Publish message by reading from `stdin`

echo {{message}} | kcat -P -t {{topic}} -b {{brokers}}

Publish messages by reading from a file

kcat -P -t {{topic}} -b {{brokers}} {{path/to/file}}

Context

tldr-pages: common/kcat

Revisions (0)

No revisions yet.