How do I delete a Kafka Consumer Group to reset offsets?

后端 未结 4 699
北恋
北恋 2021-01-07 22:44

I want to delete a Kakfa consumer group so that when the application creates a consumer and subscribes to a topic it can start at the beginning of the topic data.

Th

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-07 23:10

    If you use Java client, you can first get the beginning offset.

    TopicPartition partition = new TopicPartition("YOUR_TOPIC", YOUR_PARTITION);
    Map map = consumer.beginningOffsets(Collections.singleton(partition));
    

    And the offset that consumer using to start processing, (if not delete the consumer group).

    Long committedOffset = consumer.committed(partition).offset();
    

    Now, if you think start from committedOffset is ok, just poll records. if you want the beginning offset, consumer.seek(partition, map.get(partition));

提交回复
热议问题