So I got some annoying offset commiting case with my kafka consumers. I use 'kafka-node' for my project. I created a topic. Created 2 consumers within a consumer-group over 2 servers. Auto-commit set to false. For every mesaage my consumers get, they start an async process which can take between 1~20sec, when the process done the consumer commits the offset.. My problem is: There is a senarios in which, Consumer 1 gets a message and takes 20sec to process. In the middle of the process he gets another message which takes 1s to process. He finish the second message processing, commit the offset, then crashes right away. Causing the previous message processing to fail. If I re run the consumer, hes not reading the first message again, because the second message already commited the offsst which is greater than the first. How can i avoid this?
Kafkaconsumer.on('message', async(message)=>{
await SOMETHING_ASYNC_1~20SEC;
Kafkaconsumer.commit(()=>{});
});