Код: Выделить всё
@RetryableTopic(
attempts = "3",
backoff = @Backoff(delay = 1000),
kafkaTemplate = "kafkaTemplate",
listenerContainerFactory = "customKafkaListenerContainerFactory")
< /code>
@KafkaListener(
topics = "my-topic",
groupId = "my-group",
containerFactory = "customKafkaListenerContainerFactory")
< /code>
public void listen(String message) {
if (!processMessage(message)) {
throw new RuntimeException("Processing failed");
}
}
I want to prevent the exception from propagating or appearing as unhandled
I also tried adding a @DltHandler method to handle final failures:
Код: Выделить всё
@DltHandler
public void handleDlt(String message) {
log.warn("Message permanently failed after retries: {}", message);
}
< /code>
Этот метод вызывает правильно, когда сообщение приземляется в DLT. Хотя @dlthandler
Подробнее здесь: https://stackoverflow.com/questions/797 ... n-spring-k