Kafka binder skips failed input records when DLQ publication fails

未关闭
#3,350 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@itsgourav62 已经在做这个了。

开始于 2026年11月28日。

  • #3352 来自 @itsgourav62 —— 未关闭

评估

难度
4/5
预计耗时
3-5 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
java, kafka, spring, spring-boot

调研方向

Start with DlqSender.sendToDlq() in binders/kafka-binder/spring-cloud-stream-binder-kafka/src/main/java/org/springframework/cloud/stream/binder/kafka/KafkaMessageChannelBinder.java and trace its send failure handling and manual acknowledgment. Reproduce the reported case with the embedded Kafka integration test setup; done means a failed DLQ send leaves the input offset eligible for redelivery while successful DLQ publication retains the expected behavior.

由索引模型根据 Issue 内容生成。

描述

bug
Describe the issue

With enableDlq=true, the Kafka binder swallows DLQ publication failures and allows the input offset to be committed, even though neither processing nor DLQ publication succeeded.

The issue also occurs with dlqProducerProperties.sync: true; synchronous publication does not prevent it.

To Reproduce
  1. Configure a non-batch Kafka consumer with:
    • An explicit consumer group.
    • enableDlq: true and a configured dlqName.
    • dlqProducerProperties.sync: true.
    • ackMode: RECORD.
  2. Make processing throw an exception.
  3. Force DLQ publication to fail—for example, configure a DLQ value serializer that throws SerializationException.
  4. Publish a record and wait for processing retries to be exhausted.
  5. Observe Error sending to DLQ being logged, but the consumer group's committed offset advancing past the failed record.
  6. Publish another record to the same partition and observe that consumption continues.
Versions of the framework
  • Spring Boot: 4.2.0
  • Spring Cloud: 2026.0.0
  • Spring Cloud Stream Kafka binder: 5.1.0
  • Spring Kafka: 4.2.0
Expected behavior

A failed DLQ publication should not count as successful recovery. The input record should remain eligible for redelivery rather than having its offset committed.

Verification performed

An embedded-Kafka integration test confirmed through Kafka's Admin API that:

  • The failed record's offset was committed before any subsequent record was published.
  • The DLQ remained empty.
  • Subsequent records were consumed.

An external-cluster test also demonstrated the DLQ failure followed by continued consumption and a commit attempt past the failed record.

Additional context

In DlqSender.sendToDlq(), the binder waits for the send result, but catches publication exceptions and only logs them without rethrowing.

Additionally, manual acknowledgment occurs in finally, regardless of publication success.

This report concerns the non-transactional Kafka binder with enableDlq, not the Kafka Streams binder.

主要语言
Java
星标
1.1k
派生
657
平均合并
1 天 18 小时
30 天内合并 PR
8

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

spring-cloud/spring-cloud-stream 的其他 Issue

查看 spring-cloud/spring-cloud-stream 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。