Kafkajs: Does eachMessage commits if an error is thrown inside of it?

Created on 26 Mar 2020  路  4Comments  路  Source: tulios/kafkajs

I am s beginner on Kafka and also this library. I need the offset to be committed only after the code successfully finishes in the eachMessage callback. Does this work out of the box? I mean, if I throw an error inside the callback, the offset won't be committed? Or is the offset automatically committed no matter what happens in eachMessage's callback?

question

Most helpful comment

yes and you can configure how aggressive you want the auto-commit to be
https://kafka.js.org/docs/consuming#autocommit

All 4 comments

Yes, if you throw an error inside eachMessage it won't commit the offset.

Hi tulios, thank you for the help. Based on this, I should keep autoCommit: true, right?

yes and you can configure how aggressive you want the auto-commit to be
https://kafka.js.org/docs/consuming#autocommit

Feel free to re-open the issue if you have more questions

Was this page helpful?
0 / 5 - 0 ratings