I was trying to make kafka consumer which would collect messages for a particular amount of time after that I could manually commit with the messages that has been collected. But I could not find a method or api from shopify sarama that could be used to commit a message or a batch of messages , Please help out
2
Answers
You could use the Interval params of the AutoCommit field of the Offsets Config:
As example:
With autocommit you don’t have full control on when it’s happening anyway. It’s periodic and happens behind the scenes for you.
If it’s not ok for you you can also use the
ConsumerGroupSession.MarkOffset(topic string, partition int32, offset int64, metadata string)
for committing whenever you want (so even after a specific amount of time) an offset as the last of a batch of consumed messages.