CommitFailedException Commit cannot be completed since the group has already rebalanced and assigned the partitions to another member

后端 未结 2 424
别那么骄傲
别那么骄傲 2020-12-25 11:23

I was using kafka 0.10.2 and now faced a CommitFailedException. like:

Commit cannot be completed since the group has already rebalanced and assigned

相关标签:
2条回答
  • 2020-12-25 11:45

    Hi For this you need to handle the rebalancing condition in your code and should process the ongoing message and commit it before rebalancing

    Like :

    private class HandleRebalance implements ConsumerRebalanceListener {
        public void onPartitionsAssigned(Collection<TopicPartition> partitions) {
            // Implement what you want to do once rebalancing is done.
        }
    
        public void onPartitionsRevoked(Collection<TopicPartition> partitions) {
            // commit current method
        }
    }
    

    and Use this syntax for subscribing the topic :

    kafkaConsumer.subscribe(topicNameList , new HandleRebalance())

    The advantage of doing this :

    1. Messages will not repeat when the rebalancing is taking place.

    2. No commit fail exception

    0 讨论(0)
  • 2020-12-25 11:52

    session.timeout.ms set on the consumer should be less than the group.max.session.timeout.ms set on Kafka broker.

    This resolved the issue for me.

    Credit to github link Commit Failures

    0 讨论(0)
提交回复
热议问题