Monday, 19 August 2019

kafka commit and acknoledge


https://segmentfault.com/a/1190000011541255

if you set auto commit to false


config.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, false);

and you set act model to manual:

factory.getContainerProperties().setAckMode(AckMode.MANUAL_IMMEDIATE);

that means you need to call


acknowledgment.acknowledge();

manually to let kafka knows you have processed the data. otherwise, kafka will send you this message again if you restart.

when the auto commit is true, kafka will auto ack once you consumed the message.

No comments:

Post a comment