As per what I read on internet, method annotated with Spring @KafkaListener will commit the offset in 5 sec by default. Suppose after 5 seconds, the offset is committed but the processing is still going on and in between consumer crashes because of some issue, in that case after rebalancing, the partition will be assigned to other consumer and it will start processing from next message because previous message offset was committed. This will result in loss of the message.
So, do I need to commit the offset manually after processing completes? What would be the recommended approach?
Again, if processing is done, and just before commit, the consumer crashed, then how to avoid the message duplication in this case.
Please suggest the way which will avoid message loss and duplication. I am using Spring KafkaListener with default configuration.