Merge/noti kafak into develop - #84
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces Kafka integration for notifications, including infrastructure setup in Docker, configuration in Spring, and updating event DTOs for JSON serialization. Feedback focuses on maintaining architectural consistency by using ApplicationEventPublisher instead of direct KafkaTemplate calls to preserve transactional integrity. Additionally, the reviewer recommends externalizing hardcoded configurations via @value, separating Kafka settings into a dedicated configuration class, and removing legacy listener code that was left commented out.
| import com.catchtable.reservation.entity.ReservationStatus; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.context.ApplicationEventPublisher; | ||
| import org.springframework.kafka.core.KafkaTemplate; |
There was a problem hiding this comment.
KafkaTemplate을 직접 사용하는 대신 기존의 ApplicationEventPublisher를 사용하는 것이 좋습니다. NotificationKafkaPublisher가 이미 ApplicationEvent를 구독하여 트랜잭션 커밋 후 Kafka 메시지를 발행하는 역할을 수행하고 있으므로, 이를 활용하여 일관성을 유지하십시오.
| import org.springframework.kafka.core.KafkaTemplate; | |
| import org.springframework.context.ApplicationEventPublisher; |
|
|
||
| private final PaymentRepository paymentRepository; | ||
| private final ApplicationEventPublisher eventPublisher; | ||
| private final KafkaTemplate<String, Object> kafkaTemplate; |
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.kafka.annotation.EnableKafka; | ||
| import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory; | ||
| import org.springframework.kafka.core.*; |
There was a problem hiding this comment.
@value 어노테이션을 사용하여 설정을 외부화하기 위해 필요한 임포트를 추가하십시오.
| import org.springframework.kafka.core.*; | |
| import org.springframework.beans.factory.annotation.Value; | |
| import org.springframework.kafka.core.*; |
|
|
||
| @EnableKafka | ||
| @Configuration | ||
| public static class KafkaConfig { |
| @Configuration | ||
| public static class KafkaConfig { | ||
|
|
||
| private final String bootstrapServers = "localhost:9092"; |
There was a problem hiding this comment.
bootstrapServers 주소가 하드코딩되어 있습니다. 환경별로 유연하게 관리할 수 있도록 @value를 사용하여 application.yml 설정 파일에서 값을 가져오도록 수정하십시오.
| private final String bootstrapServers = "localhost:9092"; | |
| @Value("${spring.kafka.bootstrap-servers:localhost:9092}") | |
| private String bootstrapServers; |
| log.info("[예약 취소 알림] userId: {}, reservationId: {} 알림 생성 완료", event.getUserId(), event.getReservationId()); | ||
| } | ||
| } | ||
| //package com.catchtable.notification.listener; |
📢 기능 설명
필요시 실행결과 스크린샷 첨부
연결된 issue
연결된 issue를 자동을 닫기 위해 아래 {이슈넘버}를 입력해주세요.
close #{이슈넘버}
✅ 체크리스트