Kafka binder skips failed input records when DLQ publication fails

Offen
#3,350 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@itsgourav62 arbeitet bereits daran.

Seit 28.11.2026.

  • #3352 von @itsgourav62 — offen

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
55/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
java, kafka, spring, spring-boot

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
Java
Sterne
1.1k
Forks
657
Ø Merge
1 T. 18 Std.
Gemergte PRs (30 T.)
8

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus spring-cloud/spring-cloud-stream

Alle Issues in spring-cloud/spring-cloud-stream

Ähnliche Issues

Weitere Issues zu Java

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.