I have a kafka consumer application where in the listener method is annotated with @Kafkalistener annotation. I have provided the topic names and the container as inputs for this annotation. This method has arguments of type Message and also Acknowledgement. This method listens to any kafka messages and once it receives, processes it and stores in the DB. After this, I commit the offset manually using acknowledgement.acknowledge() method. Now, if any exception occurs before this line, the offset will not be committed manually. But, I have seen that the container property ackOnError is by default set to true. I wish to get the same message and process it until it succeeds and do not want to move the pointer forward which if moved, may result in loss of messages. For this am planning to take the following approach.
1) Listener class will implement the ConsumerSeekAware interface. The ConsumerSeekCallback will be referred by a ThreadLocal instance and using this the seek method will be called for the same message which was failed to get processed.
2) Set max-poll-records to 1.
Please help me decide if this is the right approach. Am not using Spring kafka 2.x but rather 1.2.x. Also, currently I have set the auto.commit.offset property to false and also ackMode to manual.