kafka-workshop
  • WWCode Dublin - Kafka Workshop
  • Setup your Environment
  • Start your Kafka server
  • Managing Topics
  • Producer
  • Consumer
  • Python Client - Overview
  • Producer in Python
  • Consumer in Python
Powered by GitBook
On this page
  • What is the Consumer?
  • Consume messages

Consumer

Congratulations, you're a rock star ! Let's finally learn how to consume from a topic and particular partition.

What is the Consumer?

The consumer is the other side of the road, where services and applications can subscribe to a Topic and start consuming messages from them.

Few characteristics about the consumers:

  • It works with subscription against 1+ topic

  • It use a pull request method against the brokers

  • Keeps a record of the offset that it reads from

  • Responsible for the offset commit

  • It attach itself to a Consumer Group

Now let's see how we can consume the messages we have been producing from the other side.

But, before that take a look to the kafka-console-consumer.sh script and its options. Looking at the usage scripts is helpful and save you a lot of time when you are starting to play with it.

Kafka Console Consumer Help

./kafka-console-consumer.sh

Consume messages

Use the Kafka console consumer to Consume from the topic you send messages to in the previous section.

Initially you can consume messages as simply as:

Consume messages from Cli
./kafka-console-consumer.sh --topic [TOPIC_NAME] --bootstrap-server localhost:9092

Bonus Exercise

  • Try to send 5 new messages and consume only 3

  • Try to consume the first 3 messages that arrived from the very beginning to the topic

Extra:

If you completed the exercise about sending messages with a Key:

  • Consume the messages and try to print the key too :)

  • If you have +1 partitions in any of your topics , go ahead and generate 3 messages with different key for each and try to consume them add see what happens :)

PreviousProducerNextPython Client - Overview

Last updated 6 years ago