Spring Cloud Stream - 由于反序列化错误,在发送到 dlq 时不提交偏移量,直到处理有效记录

问题描述

将 useNativeDecoding 设置为 true 时,如果记录因反序列化错误而失败,则不会提交偏移量,直到它收到有效记录。但是当将 useNativeDecoding 设置为 false 时,偏移量会被提交。我们想使用 nativeDecoding,因为如果我们使用 spring 提供的编码/解码,spring cloud 框架会在拓扑中添加额外的处理节点。

使用 Spring Cloud 版本 - Hoxton.SR7

以下是我们当前的配置 -

spring.cloud.stream:
  kafka:
    binder:
      auto-create-topics: false
      configuration:
        default.key.serde: org.apache.kafka.common.serialization.Serdes$StringSerde
        default.value.serde: org.springframework.kafka.support.serializer.JsonSerde
    streams:
      binder:
        configuration:
          processing.guarantee: exactly_once
          commit.interval.ms: 100
          auto.register.schemas: false
          max.task.idle.ms: 5000
        serdeError: sendToDlq
      bindings:
        inputbinding:
          consumer:
            applicationId: sample-application
            dlqName: topic.dlq
            valueSerde: com.service.serde.JSONSerde
            enableDlq: true
            dlqPartitions: 0
            autoCommitOffset: true
            autoCommitOnError: true
            configuration:
              max.poll.interval.ms: 30000
        outputbinding:
          producer:
            valueSerde: io.confluent.kafka.streams.serdes.avro.SpecificAvroSerde
  bindings:
    inputbinding:
      destination: topic.input.json
    outputbinding:
      destination: topic.output.avro

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)