-
Notifications
You must be signed in to change notification settings - Fork 1
도메인 이벤트 기반 색인 파이프라인 Kafka 도입 #159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 15 commits
7fc0bef
23d5c2c
9b4fb24
eeab1b6
d5edabd
f750cc2
f18a242
bda2fce
ce6a906
caf4d33
90b87f8
cd3c782
6d413b0
bbb4623
83116ce
60a3b56
c804065
c4eac26
57daacf
56a8378
cd7f906
9519b88
918309d
0299228
c49eff3
b261fea
8100e0c
b757262
59d2de9
565d730
2e0bcd9
a8c7dfc
ce42856
6458bb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package dooya.see.adapter.integration.kafka; | ||
|
|
||
| import dooya.see.application.post.required.PostEventPublisher; | ||
| import dooya.see.domain.shared.DomainEvent; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Slf4j | ||
| @Component | ||
| @RequiredArgsConstructor | ||
| @ConditionalOnProperty(value = "see.kafka.enabled", havingValue = "false", matchIfMissing = true) | ||
| public class DirectPostEventPublisher implements PostEventPublisher { | ||
| private final PostEventProcessor postEventProcessor; | ||
|
|
||
| @Override | ||
| public void publish(DomainEvent event) { | ||
| log.debug("Kafka 비활성화 상태 - 도메인 이벤트를 직접 처리합니다: {}", event); | ||
| postEventProcessor.process(event); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package dooya.see.adapter.integration.kafka; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
| import org.springframework.kafka.annotation.KafkaListener; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| @Slf4j | ||
| @Component | ||
| @RequiredArgsConstructor | ||
| @ConditionalOnProperty(value = "see.kafka.enabled", havingValue = "true") | ||
| public class PostEventConsumer { | ||
| private final PostEventProcessor postEventProcessor; | ||
|
|
||
| @KafkaListener( | ||
| topics = "${see.kafka.topics.post-events:post-events}", | ||
| groupId = "${spring.kafka.consumer.group-id:post-indexer-group}" | ||
| ) | ||
| public void consume(PostEventMessage message) { | ||
| log.debug("Kafka 이벤트 수신: {}", message); | ||
| postEventProcessor.process(message); | ||
| } | ||
|
Comment on lines
16
to
24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major 🧩 Analysis chain소비자 오류 처리와 역직렬화 설정을 명시하세요 현재 예외 시 처리 전략(DLT/재시도/백오프)이 보이지 않습니다. 또한 POJO 페이로드를 직접 받으려면 JsonDeserializer의 기본 타입/Trusted Packages 설정이 필요합니다. 전용 컨테이너 팩토리와 CommonErrorHandler를 사용하도록 리스너에 명시해 주세요. 예시(리스너에 컨테이너 팩토리 명시): - @KafkaListener(
+ @KafkaListener(
topics = "${see.kafka.topics.post-events:post-events}",
- groupId = "${spring.kafka.consumer.group-id:post-indexer-group}"
- )
+ groupId = "${spring.kafka.consumer.group-id:post-indexer-group}",
+ containerFactory = "postEventKafkaListenerContainerFactory"
+ )
public void consume(PostEventMessage message) {다음 스캔으로 설정 유무를 확인해 주세요: Based on learnings 🏁 Script executed: #!/usr/bin/env bash
# JsonDeserializer/Trusted Packages/에러핸들러/컨테이너 팩토리 존재 여부 점검
rg -nP -C2 '(JsonDeserializer|CommonErrorHandler|DefaultErrorHandler|ConcurrentKafkaListenerContainerFactory|postEventKafkaListenerContainerFactory|spring\.kafka\.consumer\.properties\.spring\.json\.trusted\.packages|JsonDeserializer\.VALUE_DEFAULT_TYPE)'Length of output: 3779 Length of output: 2622 🏁 Script executed: #!/bin/bash
# Check if @KafkaListener in PostEventConsumer specifies containerFactory
rg -nP -A5 '@KafkaListener' src/main/java/dooya/see/adapter/integration/kafka/PostEventConsumer.javaLength of output: 288 Length of output: 0 @KafkaListener에 containerFactory를 지정하고 에러 핸들러를 설정하세요 현재 상태 검증 결과:
필수 수정 사항:
🤖 Prompt for AI Agents |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package dooya.see.adapter.integration.kafka; | ||
|
|
||
| import java.io.Serializable; | ||
|
|
||
| public record PostEventMessage(PostEventType type, Long postId) implements Serializable { | ||
| static PostEventMessage created(Long postId) { | ||
| return new PostEventMessage(PostEventType.CREATED, postId); | ||
| } | ||
|
|
||
| static PostEventMessage updated(Long postId) { | ||
| return new PostEventMessage(PostEventType.UPDATED, postId); | ||
| } | ||
|
|
||
| static PostEventMessage deleted(Long postId) { | ||
| return new PostEventMessage(PostEventType.DELETED, postId); | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.