Skip to content
Kafka Is Fun

SpringSpring Kafka Advanced

What is SeekToCurrentErrorHandler (now DefaultErrorHandler) in Spring Kafka?

Reference answer

DefaultErrorHandler replaces SeekToCurrentErrorHandler (and RecoveringBatchErrorHandler). It implements CommonErrorHandler, so it works for record and batch listeners, and handles exceptions thrown by @KafkaListener methods. By default it seeks the consumer so the failed record and the unprocessed records of that poll are redelivered; offsets of the records already processed are committed first. Retries follow a BackOff, and the default is FixedBackOff(0L, 9): no delay and 9 retries, so 10 attempts in total. In FixedBackOff(interval, maxAttempts) the second argument counts retries, so FixedBackOff(1000L, 3) means 3 retries, 4 deliveries. When retries are exhausted the recoverer is invoked; the default recoverer only logs the record at ERROR, and a DeadLetterPublishingRecoverer can publish it to a dead letter topic instead (named <originalTopic>-dlt by default). Supports FixedBackOff and ExponentialBackOff (use ExponentialBackOffWithMaxRetries to cap retries). Some exceptions, such as DeserializationException and MessageConversionException, are not retried and go straight to the recoverer; add more with addNotRetryableExceptions. Configure: factory.setCommonErrorHandler(new DefaultErrorHandler(recoverer, new FixedBackOff(1000L, 3))).

Expected key concepts: DefaultErrorHandler, SeekToCurrentErrorHandler, CommonErrorHandler, BackOff, FixedBackOff, ExponentialBackOff, DeadLetterPublishingRecoverer, recoverer, seek, retries, addNotRetryableExceptions

How did that feel?

Your own verdict, not the score. It shows up next to this question in the list, so you can come back to the shaky ones.