Skip to content
Advertisement

kafka Offset commit failing org.apache.kafka.clients.consumer.CommitFailedException

I have written a kafka consumer using spring-kafka library (spring-boot-starter-parent 2.3.4.RELEASE). I have following consumer configuration in my code

JavaScript

Following is my listener method :

JavaScript

Here I am reading 1 message at a time, apply business logic and use ack.acknowledge() to commit offset, but what I have seen, sometime offset commit succeed but many time I get org.apache.kafka.clients.consumer.CommitFailedException on line ack.acknowledge(). Here I can confirm that business logic is completed in 2 sec max. Following is the detailed exception:

JavaScript

Can someone please help me why this is happening, because default poll interval is 5 min and group coordinator should not kickout the consumer if processing just takes 2 sec.

Advertisement

Answer

You must be able to process max.poll.records (default 500) in max.poll.interval.ms (default 300000 – 5 mins).

If it takes 2 seconds per record, it will take up to 16.6667 minutes to process the batch, and you will be kicked out of the group.

Reduce max.poll.records and/or increase max.poll.interval.ms.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement