OnCallReadyStart learning

kafka-console-consumer.sh: read data from Kafka topics and write it to standard output

kafka-console-consumer.sh [options]

Options you will use

--bootstrap-server <String: server to connect to>
REQUIRED: the Kafka broker(s) to connect to, host:port[,host:port]. Give more than one: the first may be the broker that is down.
--topic <String: topic>
the topic to consume.
--include <String: regex>
consume every topic matching the regex.
--group <String: group>
the consumer group: joins it and commits offsets (never a production group).
--from-beginning
start at the oldest record if the group has no committed offset (default: the end).
--partition <Integer>
read one partition (not with --group).
--offset <String>
with --partition: earliest, latest or an offset number.
--max-messages <Integer>
exit after this many records.
--timeout-ms <Integer>
exit if no record arrives for this long (an ERROR line + TimeoutException, not a failure of the cluster).
--formatter-property <String: prop>
print.timestamp, print.partition, print.offset, print.key, print.headers, key.separator (--property is deprecated).
--isolation-level <String>
read_committed to skip records of aborted transactions.

Examples

$ kafka-console-consumer.sh --bootstrap-server kafka-1:9092 --topic orders --from-beginning --max-messages 3

the three oldest records

$ kafka-console-consumer.sh --bootstrap-server kafka-1:9092 --topic orders --partition 0 --offset earliest --formatter-property print.offset=true --timeout-ms 5000

one partition with offsets

Gotchas

Taught in

Try kafka-console-consumer.sh in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.