Kafka binder skips failed input records when DLQ publication fails

Ouverte
#3,350 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

@itsgourav62 y travaille déjà.

Depuis le 28/11/2026.

  • #3352 par @itsgourav62 — ouverte

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
55/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
java, kafka, spring, spring-boot

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

Langage dominant
Java
Étoiles
1.1k
Forks
657
Merge moyen
1 j 18 h
PR mergées (30 j)
8

Préparer son environnement

Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de spring-cloud/spring-cloud-stream

Toutes les issues de spring-cloud/spring-cloud-stream

Issues similaires

Plus d'issues Java

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.