微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决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 举报,一经查实,本站将立刻删除。