Let's say we are using Kafka with manual commits. We are processing the incoming message. But if there is a failure in processing for any reason, we want to reread the message again and we want to ensure that as long as it is not comitted, it will be reprocessed.
while True:
try:
msg = consumer.poll()
out_msg = process(msg)
consumer.commitAsync()
except:
print('error occurred. not comitting')
If I have the topic with the following contents 1 2 3 4 5 6 7 and failure starts happening from offset 4 onwards, then how do I keep reprorcessing 4 5 6 7? I don't have to get stuck on 4 because it is the first occurence of failure but that is fine as well.
If I have this basic consume loop, I want to reprocess the same message multiple times until I can call commit on it. Whether I use commitAsync() or commitSync() does not matter for me, as long I will eventually commit every message. What Kafka setup is required to achieve this?