Scrivio Interview library
ConceptFoundations6 min read · updated 13 November 2026

Sooner or later every consumer meets a record it cannot process, and the Spring Kafka error handler decides what happens to that partition next.

What is a poison message? A Spring Kafka listener consumes 12 partitions with three consumers, and the record at offset 1,204 on partition 3 has a field the code cannot parse. The container uses a DefaultErrorHandler with FixedBackOff(1000, 9). Describe what happens to partition 3, to the other partitions, and after the retries run out, and how you would treat such a record instead.

A poison message is a record that fails every time it is processed, so retrying it only delays everything behind it. With DefaultErrorHandler and FixedBackOff(1000, 9), the handler seeks back and the record at offset 1,204 is tried 10 times about a second apart while the consumer thread that owns partition 3 waits, so partition 3 and the other partitions of that consumer stall while the other two consumers continue. When retries run out, the default recoverer only logs the failure and the offset moves on, which silently loses the record unless a DeadLetterPublishingRecoverer sends it to a dead-letter topic. Parsing and validation errors should be marked not retryable so they go straight to the dead-letter topic.

Why this question is asked

Every Kafka consumer eventually meets a record it cannot process: a malformed field, a schema mismatch, a value the code did not expect. What happens next is decided by the container's error handler, and its defaults surprise many teams, both in how long a partition stalls and in what happens to the record at the end. Interviewers ask this question to see whether we can trace that behaviour precisely and configure it sensibly. In this answer, we will define a poison message, follow the record through the retries, see which partitions stall and why, look at what happens when retries run out, and then configure classification and a dead-letter topic.

1What a Poison Message Is

Failures come in two kinds. A transient failure depends on something outside the record: a database timeout, a downstream service returning 503, a network hiccup. Trying again a little later often works. A permanent failure depends on the record itself: a field the code cannot parse, a value that violates a validation rule. Trying again gives exactly the same result.

A poison message is a record that causes a permanent failure. Because Kafka delivers a partition's records in order, a consumer that keeps retrying a poison message cannot move on to the records behind it. Retrying it is not just useless; it actively delays every later record on that partition.

2Following Offset 1,204 Through the Retries

Spring Kafka's DefaultErrorHandler handles exceptions thrown by the listener. When the record at offset 1,204 on partition 3 fails, the handler does not skip it. It seeks the consumer back, so the failed record and the remaining records from the last poll are fetched again, and the failed one is redelivered first.

FixedBackOff(1000, 9) means a one-second interval and nine retries. Counting the first delivery, the record is tried 10 times in total, with about one second between attempts, so roughly nine seconds pass before the handler gives up. During each back-off, the consumer thread that owns partition 3 is held: it is not processing anything else.

Java
@Bean
DefaultErrorHandler errorHandler() {
return new DefaultErrorHandler(new FixedBackOff(1000L, 9)); // 1 delivery + 9 retries = 10 attempts
}
// partition 3, offset 1204: attempt 1 at t=0s -> NumberFormatException
// attempt 2 at t=1s -> NumberFormatException
// ...
// attempt 10 at t=9s -> NumberFormatException
// then: recoverer called, offset 1205 is next
Step throughWhat the error handler does with offset 1,204
  1. Listener throws for offset 1,204
  2. Exception classified as retryable?
    Yesseek back, wait 1 s, redeliverNoskip retries, go to recoverer
  3. Attempts left (10 in total)?
    Yestry againNocall recoverer
  4. Recoverer: log only, or publish to DLTdefault logs at error level
  5. Commit offset; continue at 1,205

5 steps in order. Play them, or step through them one at a time.

3Which Partitions Stall

Twelve partitions over three consumers means each consumer owns four partitions, say consumer 1 owns partitions 0 to 3. Records after offset 1,204 on partition 3 obviously wait, because order on a partition is preserved. But partitions 0, 1 and 2 also stall, because they share the same consumer thread, and that thread is busy waiting and redelivering the failed record. Partitions 4 to 11, owned by the other two consumers, continue normally.

Nine seconds is tolerable. But the same configuration with a longer back-off, or a poison message that reappears several times, makes a quarter of the topic stop repeatedly, and lag alerts fire for partitions that have nothing wrong with them.

4When the Retries Run Out

After the tenth failure, the DefaultErrorHandler calls its recoverer. With no recoverer configured, the default one logs the failed record at error level and returns, and the handler then commits the offset past the record. Processing continues at offset 1,205.

That is silent data loss. The record is gone from the consumer's point of view, and unless someone reads the logs, nobody knows. The fix is a DeadLetterPublishingRecoverer, which publishes the failed record to a dead-letter topic, by default named after the original with a .DLT suffix, for example orders.DLT, on the same partition number, with headers carrying the original topic, partition, offset and the exception. The record is kept, visible and can be fixed and redriven later.

5Classifying Failures

Retrying a parsing error ten times only delays the dead-letter step. So we tell the handler which exceptions are permanent with addNotRetryableExceptions: those skip the back-off and go straight to the recoverer. Timeouts and other transient errors keep the retries.

Java
@Bean
DefaultErrorHandler errorHandler(KafkaTemplate<Object, Object> template) {
var recoverer = new DeadLetterPublishingRecoverer(template); // -> orders.DLT, same partition
var handler = new DefaultErrorHandler(recoverer, new FixedBackOff(1000L, 9));
handler.addNotRetryableExceptions(
InvalidOrderException.class, // our validation failures
JsonProcessingException.class); // parsing failures in the listener
return handler;
}
// offset 1204 with a bad field: 1 attempt, then published to orders.DLT, offset 1205 next
// a database timeout: up to 10 attempts as before

Some exceptions are not retried by default already. DeserializationException, thrown when an ErrorHandlingDeserializer wraps a deserializer that failed, is one of them, together with a few conversion errors (check your version for the full list). That is why wrapping the deserializer matters: a record whose bytes cannot be deserialized becomes a not-retryable failure that the recoverer can dead-letter, instead of an exception inside poll() that the container cannot get past.

In Spring Boot, declaring a CommonErrorHandler bean like this one is enough for the auto-configured listener container factory to use it. The dead-letter topic needs at least as many partitions as the original, because the recoverer writes to the same partition number by default.

6Follow-up questions

Why not simply catch every exception in the listener and log it?

Because that turns every failure, including transient ones, into silent loss, and it hides the problem from metrics and alerts. Letting the error handler classify failures keeps retries for transient errors and sends permanent ones to a dead-letter topic where they are counted, alerted on and can be redriven.

How would non-blocking retry topics change this picture?

With @RetryableTopic, a failed record is published to a retry topic and the main consumer moves on at once, so partitions 0 to 3 would not stall. The cost is that the record leaves its partition's order, so later records for the same key can be processed first. For independent records that is a good trade; for dependent ones it is not.

7Conclusion

In this answer, we saw that a poison message fails every time, so retries only delay the records behind it. With DefaultErrorHandler and FixedBackOff(1000, 9), the handler seeks back and tries offset 1,204 ten times about a second apart, holding the consumer thread, so partition 3 and the other partitions of that consumer stall while the other consumers continue. When retries are exhausted, the default recoverer only logs and the offset moves on, which is silent loss unless a DeadLetterPublishingRecoverer publishes the record to a dead-letter topic. Marking parsing and validation exceptions as not retryable sends them there at once, and DeserializationException is not retried by default.

What to say in the interviewAbout 80 seconds aloud

Open with

A poison message is a record that fails every time it is processed, like one with a field the code cannot parse, so retrying it only delays everything behind it.

Then, if they want more

With a DefaultErrorHandler and FixedBackOff of 1000 and 9, when offset 1,204 on partition 3 fails, the handler seeks back so the record is redelivered. It is tried 10 times in total, the first attempt plus nine retries, about one second apart, and the consumer thread that owns partition 3 is held during the back-off.

With 12 partitions and three consumers, that consumer owns four partitions, so records after 1,204 on partition 3 wait, and its other three partitions stall too, while the partitions on the other two consumers continue. When retries are exhausted, the default recoverer just logs the failure and the offset moves past the record, which is silent data loss.

So I would configure a DeadLetterPublishingRecoverer that sends it to a dead-letter topic with headers for the original topic, partition, offset and exception. And I would classify failures: register parsing and validation exceptions with addNotRetryableExceptions so they go straight to the dead-letter topic, and keep retries only for transient errors such as timeouts. DeserializationException, from an ErrorHandlingDeserializer, is not retried by default.

About this answer

Last updated
13 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Apache Kafka documentation
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "What is a poison message? A Spring Kafka listener consumes 12 partitions with three...": https://scrivio-interview-library.netlify.app/spring-boot/kafka-design/5557e1bded/