From the course: Troubleshooting and Debugging Kafka
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Monitoring consumption in a consumer group - Kafka Tutorial
From the course: Troubleshooting and Debugging Kafka
Monitoring consumption in a consumer group
We have a producer running and producing messages that are being sent to all 12 partitions. Now, let's take a look at the consumer code that we'll use to consume these messages. Now, I have code for three consumers here. But first, I'm going to get started with just one consumer running. That's going to be consumer A. So let's take a look at the code here. From Confluent Kafka, we import the consumer class. We instantiate a consumer object on Lines 3 through 6. Notice, the group ID that I've specified for the consumer. This is the consumer group ID, so this consumer will be part of the payment group. To start off with, we'll have exactly one consumer here in this payment group and that will be reading from all partitions on the customer_payments topic. Notice, on Line 8, I call consumer.subscribe and have it subscribe to customer_payments. That's the topic that we set up earlier. Within our main module, I set message count to zero so that I can commit the consumer messages every 10…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.