Search code examples
spring-bootspring-kafka

Consequences of no commit/acknowledge to Kafka after consuming a message (with auto commit disabled)


I have a multi-node Spring Boot application running on Kubernetes. Each node has 1 listener each. Since I have facing issues with auto commit while using spring-kafka, I have now switched to a MANUAL_IMMEDIATE acknowledgement mode. This is what helped me do that

Now, I am acknowledging to Kafka at the end of the execution of my service. What would happen, if for some reason I am not able to acknowledge to Kafka? Will the listener read that message again after a cooldown? If yes, how can I control this cooldown period? If not, what happens to that message?


Solution

  • The listener will not re-consume the message unless the consumer is restarted, or a rebalance occurs.

    Kafka maintains 2 pointers for each consumer/partition; the position (last read record) and the committed offset. When a consumer starts, or a rebalance occurs, the position is set to the committed offset. The position is only changed by fetching new records, or if a seek is performed on the consumer for that partition.