Kafka commit offset
It depends on how you commit:
On commitSync
assuming you commit each offset separately like in your example, if offset 1 is not committed it will retry to commit that offset until it succeeds or until it encounters nonRetryable failure.
One drawback of that mechanism is that the application is blocked until the broker responds and therefor limit the application throughput.
On commitAsync
on the other hand, there is no retry in case it failed to commit offset 1. The reason for that is that by the time the broker responds get back to your Kafka client there may be later commit that was already successful.
Imagine on your example that commit of message with offset 1 was failed due to temporary network issue. Meanwhile the application already processed successfully message with offset 2. If we now retry previous failed commit it might succeed to commit offset 1 after 2 was already committed. In a case of rebalance, this will cause more duplicated.
Consequences of no commit/acknowledge to Kafka after consuming a message (with auto commit disabled)
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.
Related Topics
Spring Security Configuration Filter Any Requests Except a Specific Endpoint
Classcastexception Because of Classloaders
Java Input Validation for Number Range and Numeric Values Only With Counter
Scheduling a Job With Spring Programmatically (With Fixedrate Set Dynamically)
Java Spring @Scheduled Tasks Executing Twice
Maven: Best Way of Linking Custom External Jar to My Project
Spring Boot JPA - Onetomany Relationship Causes Infinite Loop
How to Mark Cucumber Junit Step as Failed But Continue
Keep the Order of the Json Keys During Json Conversion to Csv
How to Sort Json Object in Java
Using an Empty Keystore Password Used to Be Possible
How to Add Multiple Components to a Jframe
How to Generate a Unique and Short File Name in Java
How to Delete the Content of Text File Without Deleting Itself
Sending Variable from Adapter to Activity
How to Change the Background Color of a Textfield Without Changing the Border in Javafx