Skip to content

Fix: kafka 알림 동작 안 함: @RetryableTopic 제거 + DefaultErrorHandler 복귀 - #110

Merged
jaebeom79 merged 1 commit into
mainfrom
develop
May 30, 2026
Merged

Fix: kafka 알림 동작 안 함: @RetryableTopic 제거 + DefaultErrorHandler 복귀#110
jaebeom79 merged 1 commit into
mainfrom
develop

Conversation

@jaebeom79

Copy link
Copy Markdown
Contributor

📢 기능 설명

필요시 실행결과 스크린샷 첨부

연결된 issue

연결된 issue를 자동을 닫기 위해 아래 {이슈넘버}를 입력해주세요.

close #{이슈넘버}

✅ 체크리스트

  • PR 제목 규칙 잘 지켰는가?
  • 추가/수정사항을 설명하였는가?
  • 이슈넘버를 적었는가?

@jaebeom79
jaebeom79 merged commit 2cedecb into main May 30, 2026
1 check passed

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +58 to +61
DeadLetterPublishingRecoverer recoverer = new DeadLetterPublishingRecoverer(
kafkaTemplate,
(record, ex) -> new TopicPartition(record.topic() + "-dlt", record.partition())
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

원밸 픽이 여러 개의 파티션을 가지고 잋지만 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        );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant