Kafka应用点滴(二)

您所在的位置:网站首页 ackowledge Kafka应用点滴(二)

Kafka应用点滴(二)

2023-11-26 11:19| 来源: 网络整理| 查看: 265

         当spring.kafka.consumer.enable-auto-commit设置为false,并且

          spring.kafka.listener.ack-mode=MANUAL/MANUAL_IMMEDIATE

        时,我们有3种手工提交方式:consumer.commitAsync()、consumer.commitSync()以及acknowledgment.acknowledge()。这3种方式有什么区别呢?

commitAsync()与commitSync()的区别: commitSync

          This is a synchronous commits and will block until either the commit succeeds or an unrecoverable error is encountered (in which case it is thrown to the caller).

      同步提交,是一种阻塞式方法,只有在当前消息提交成功或者遇到不可恢复的的错误时,才会继续下一步操作,eg:

while (true) { ConsumerRecords records = consumer.poll(100); for (ConsumerRecord


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3