Conversation
There was a problem hiding this comment.
Code Review
This pull request centralizes retry and dead-letter topic (DLT) handling by removing individual @RetryableTopic and @DltHandler annotations from NotificationKafkaConsumer and configuring a global DefaultErrorHandler and DeadLetterPublishingRecoverer in KafkaConfig. Feedback was provided to use -1 as the partition index when routing to the DLT topic to prevent potential InvalidPartitionException if the DLT topic has fewer partitions than the original topic.
| DeadLetterPublishingRecoverer recoverer = new DeadLetterPublishingRecoverer( | ||
| kafkaTemplate, | ||
| (record, ex) -> new TopicPartition(record.topic() + "-dlt", record.partition()) | ||
| ); |
There was a problem hiding this comment.
원밸 픽이 여러 개의 파티션을 가지고 잋지만 DLT 픽(-dlt)은 다른 파티션 개수(예: 1개)를 가지고 잋을 경우, record.partition()을 그대로 사용하면 DLT 픽에 존재하지 않는 파티션 인덱스로 메시지를 전섑하려고 시도하여 InvalidPartitionException이 발생할 수 잋습니다.\n\n읻 문제를 방지하기 위해 TopicPartition 생성 시 파티션 번호로 -1을 전달하는 쑔이 안전합니다. DeadLetterPublishingRecoverer는 음수 파티션 값을 null로 처리하여, Kafka Producer의 기밸 파티셔너(Partitioner)가 DLT 픽의 파티션을 적절히 결정하도록 위임합니다.
DeadLetterPublishingRecoverer recoverer = new DeadLetterPublishingRecoverer(\n kafkaTemplate,\n (record, ex) -> new TopicPartition(record.topic() + "-dlt", -1)\n );
📢 기능 설명
필요시 실행결과 스크린샷 첨부
연결된 issue
연결된 issue를 자동을 닫기 위해 아래 {이슈넘버}를 입력해주세요.
close #{이슈넘버}
✅ 체크리스트