Search code examples
apache-kafkakafka-consumer-api

Kafka message not being consumed and offset not committed


I am trying to consume a Kafka message at topic and specific partition at a particular offset.

The command to consume the message is below:

bin/kafka-console-consumer.sh --bootstrap-server (server_ip) --consumer.config file --topic name --partition num --max-messages 1

I've also set auto commit to true in the config. I am able to see the message get printed to stdout but the current offsets remain unchanged. I've also tried adding a group option but then I get an error saying:

options group and partition cannot be specified together

Solution

  • When a partition is specified, consumer groups are not used. It uses the assignment API of the consumer rather than a subscription.

    Since there's no group, there's no offset that can be committed. The "current offsets" remain unchanged since consuming doesn't remove data from the topic, and there's otherwise no group to update.

    When the partition argument is removed, then a random consumer group is created, or one can be provided, and you can then describe its updated offsets with kafka-consumer-groups.sh