728x90
Kafka 내에서는 message 처리에 실패한 message 를 저장하는 별도의 topic 이 있다.
= DLT
처리 실패한 message 를 Kafka with spring 기능을 활용해서 자동 retry 를 설정할 수 있다.
이는 Transactional outout pattern 의 동작원리와는 다른 구성이다. DLT 의 경우 Kafka 자체의 message 전달 실패에만 사용이가능하다.
하나의 예로, consumer 에서 토픽을 받자말자 error 를 return 하게 되면 kafka 는 이를 오류로 인식하고 message 전달의 실패로 간주하게 된다.
하지만 consumer 전달은 잘 받고 consumer 에 연결된 서비스 로직을 수행중에 오류가 나게되면, DLT 로 message 가 저장되지 않는다.
@RetryableTopic(
attempts = 3,
backoff = @Backoff(delay = 2000, multiplier = 2.0)
delay = 1000,
multiplier = 2.0,
dltTopicSuffix = ".dlt"
include = { RecoverableException.class },
exclude = { NonRecoverableException.class }
)
@KafkaListener(groupId = "groupTest", topics = "topicTest")
public void testConsumer(String message) {
try{
call.bizLogic;
}catch(RecoverableException e){
throw e;
}catch(NonRecoverableException e){
throw e;
}
}
728x90
'AMQP > Kafka' 카테고리의 다른 글
KRaft 사용하여 Kafka 컨테이너 띄우기 (0) | 2025.03.07 |
---|---|
카프카는 어떻게 빠른 속도를 보이는 것인가? ( Kafka Buffer Pool ) (0) | 2025.02.21 |
Kafka 세팅 시 참고할 만한 내용정리 (1) | 2024.10.01 |
Kafka 세팅 docker compose yaml (2) | 2024.09.12 |