Skip to content

Merge/noti kafak into develop - #84

Merged
jaebeom79 merged 5 commits into
developfrom
merge/noti-kafak-into-develop
May 23, 2026
Merged

Merge/noti kafak into develop#84
jaebeom79 merged 5 commits into
developfrom
merge/noti-kafak-into-develop

Conversation

@jaebeom79

Copy link
Copy Markdown
Contributor

📢 기능 설명

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

연결된 issue

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

close #{이슈넘버}

✅ 체크리스트

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

@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 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;

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.

high

KafkaTemplate을 직접 사용하는 대신 기존의 ApplicationEventPublisher를 사용하는 것이 좋습니다. NotificationKafkaPublisher가 이미 ApplicationEvent를 구독하여 트랜잭션 커밋 후 Kafka 메시지를 발행하는 역할을 수행하고 있으므로, 이를 활용하여 일관성을 유지하십시오.

Suggested change
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;

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.

high

KafkaTemplate 대신 ApplicationEventPublisher를 주입받도록 수정하십시오. 이는 트랜잭션 정합성을 보장하기 위함입니다.

Suggested change
private final KafkaTemplate<String, Object> kafkaTemplate;
private final ApplicationEventPublisher eventPublisher;

import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.annotation.EnableKafka;
import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
import org.springframework.kafka.core.*;

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

@value 어노테이션을 사용하여 설정을 외부화하기 위해 필요한 임포트를 추가하십시오.

Suggested change
import org.springframework.kafka.core.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.core.*;


@EnableKafka
@Configuration
public static class KafkaConfig {

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

KafkaConfig가 SchedulerConfig의 내부 클래스로 정의되어 있습니다. 카프카 설정과 스케줄러 설정은 서로 다른 관심사이므로, 별도의 설정 클래스로 분리하여 관리하는 것이 유지보수 측면에서 바람직합니다.

@Configuration
public static class KafkaConfig {

private final String bootstrapServers = "localhost:9092";

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

bootstrapServers 주소가 하드코딩되어 있습니다. 환경별로 유연하게 관리할 수 있도록 @value를 사용하여 application.yml 설정 파일에서 값을 가져오도록 수정하십시오.

Suggested change
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;

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

카프카 도입으로 인해 더 이상 사용하지 않는 기존 리스너 코드가 주석 처리된 채로 남아 있습니다. 코드 베이스의 청결함을 위해 주석 처리된 파일은 삭제하거나 내용을 제거하는 것을 권장합니다. (다른 리스너 파일들도 동일하게 적용됩니다.)

@jaebeom79
jaebeom79 merged commit a91a13b into develop May 23, 2026
1 check passed
jaebeom79 added a commit that referenced this pull request May 23, 2026
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.

2 participants