Spring-cloud-stream kafka消费者如何自动重新获取消息?

时间:2017-01-25 06:47:40

标签: spring-cloud-stream

当我在消费者应用程序中手动确认偏移时,但我希望消费者能够自动获得未确认消息,但我无法成功。
这是我的配置yml:

cloud:
  stream:
    kafka:
      binder:
        brokers: ****:****
        za-nodes: ****
        replication-factor: 1
      bindings:
       input:
         consumer: 
         auto-commit-offset: false
         auto-commit-on-error: false
         reset-offsets: true

2 个答案:

答案 0 :(得分:0)

现在似乎没有使用属性resetOffsetshttps://github.com/spring-cloud/spring-cloud-stream-binder-kafka/issues/48#issuecomment-273111200

默认情况下,消费者的auto.offset.reset将设置为latest(即如果您使用spring.cloud.stream.bindings.input.group为使用者绑定明确设置了一个组)

答案 1 :(得分:0)

Kafka无法确认单个邮件 - 一旦保存了组/分区的偏移量,所有先前的邮件都被视为已确认' - 手动确认允许在例如异步处理消息的情况下推迟偏移提交过程(并且自动确认将在消息实际处理之前保存偏移量)。

目前不支持

resetOffsets(这是我们迁移到新的消费者客户端后我们基本上已删除的功能 - 请参阅https://github.com/spring-cloud/spring-cloud-stream-binder-kafka/issues/67),但不幸的是文档没有反映这一点。