mirror of
https://github.com/ktds-dg0501/kt-event-marketing.git
synced 2026-06-12 23:19:10 +00:00
샘플 토픽명으로 변경 (sample. 접두사 추가)
- 다른 서비스 개발자들의 운영 토픽과 충돌 방지 - MVP용 샘플 토픽: sample.event.created, sample.participant.registered, sample.distribution.completed - KafkaTopicConfig, SampleDataLoader, 3개 Consumer 모두 업데이트 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
package com.kt.event.analytics.config;
|
||||
|
||||
import org.apache.kafka.clients.admin.NewTopic;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.kafka.config.TopicBuilder;
|
||||
|
||||
/**
|
||||
* Kafka 토픽 자동 생성 설정
|
||||
*
|
||||
* ⚠️ MVP 전용: 샘플 데이터용 토픽을 생성합니다.
|
||||
* 실제 운영 토픽(event.created 등)과 구분하기 위해 "sample." 접두사 사용
|
||||
*
|
||||
* 서비스 시작 시 필요한 Kafka 토픽을 자동으로 생성합니다.
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnProperty(name = "spring.kafka.enabled", havingValue = "true", matchIfMissing = false)
|
||||
public class KafkaTopicConfig {
|
||||
|
||||
/**
|
||||
* sample.event.created 토픽 (MVP 샘플 데이터용)
|
||||
*/
|
||||
@Bean
|
||||
public NewTopic eventCreatedTopic() {
|
||||
return TopicBuilder.name("sample.event.created")
|
||||
.partitions(3)
|
||||
.replicas(1)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* sample.participant.registered 토픽 (MVP 샘플 데이터용)
|
||||
*/
|
||||
@Bean
|
||||
public NewTopic participantRegisteredTopic() {
|
||||
return TopicBuilder.name("sample.participant.registered")
|
||||
.partitions(3)
|
||||
.replicas(1)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* sample.distribution.completed 토픽 (MVP 샘플 데이터용)
|
||||
*/
|
||||
@Bean
|
||||
public NewTopic distributionCompletedTopic() {
|
||||
return TopicBuilder.name("sample.distribution.completed")
|
||||
.partitions(3)
|
||||
.replicas(1)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -52,10 +52,10 @@ public class SampleDataLoader implements ApplicationRunner {
|
||||
|
||||
private final Random random = new Random();
|
||||
|
||||
// Kafka Topic Names
|
||||
private static final String EVENT_CREATED_TOPIC = "event.created";
|
||||
private static final String PARTICIPANT_REGISTERED_TOPIC = "participant.registered";
|
||||
private static final String DISTRIBUTION_COMPLETED_TOPIC = "distribution.completed";
|
||||
// Kafka Topic Names (MVP용 샘플 토픽)
|
||||
private static final String EVENT_CREATED_TOPIC = "sample.event.created";
|
||||
private static final String PARTICIPANT_REGISTERED_TOPIC = "sample.participant.registered";
|
||||
private static final String DISTRIBUTION_COMPLETED_TOPIC = "sample.distribution.completed";
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
|
||||
+2
-2
@@ -33,9 +33,9 @@ public class DistributionCompletedConsumer {
|
||||
private static final long IDEMPOTENCY_TTL_DAYS = 7;
|
||||
|
||||
/**
|
||||
* DistributionCompleted 이벤트 처리
|
||||
* DistributionCompleted 이벤트 처리 (MVP용 샘플 토픽)
|
||||
*/
|
||||
@KafkaListener(topics = "distribution.completed", groupId = "analytics-service")
|
||||
@KafkaListener(topics = "sample.distribution.completed", groupId = "analytics-service")
|
||||
public void handleDistributionCompleted(String message) {
|
||||
try {
|
||||
log.info("📩 DistributionCompleted 이벤트 수신: {}", message);
|
||||
|
||||
+2
-2
@@ -33,9 +33,9 @@ public class EventCreatedConsumer {
|
||||
private static final long IDEMPOTENCY_TTL_DAYS = 7;
|
||||
|
||||
/**
|
||||
* EventCreated 이벤트 처리
|
||||
* EventCreated 이벤트 처리 (MVP용 샘플 토픽)
|
||||
*/
|
||||
@KafkaListener(topics = "event.created", groupId = "analytics-service")
|
||||
@KafkaListener(topics = "sample.event.created", groupId = "analytics-service")
|
||||
public void handleEventCreated(String message) {
|
||||
try {
|
||||
log.info("📩 EventCreated 이벤트 수신: {}", message);
|
||||
|
||||
+2
-2
@@ -33,9 +33,9 @@ public class ParticipantRegisteredConsumer {
|
||||
private static final long IDEMPOTENCY_TTL_DAYS = 7;
|
||||
|
||||
/**
|
||||
* ParticipantRegistered 이벤트 처리
|
||||
* ParticipantRegistered 이벤트 처리 (MVP용 샘플 토픽)
|
||||
*/
|
||||
@KafkaListener(topics = "participant.registered", groupId = "analytics-service")
|
||||
@KafkaListener(topics = "sample.participant.registered", groupId = "analytics-service")
|
||||
public void handleParticipantRegistered(String message) {
|
||||
try {
|
||||
log.info("📩 ParticipantRegistered 이벤트 수신: {}", message);
|
||||
|
||||
@@ -51,6 +51,11 @@ spring:
|
||||
enable-auto-commit: true
|
||||
key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
|
||||
value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
|
||||
producer:
|
||||
key-serializer: org.apache.kafka.common.serialization.StringSerializer
|
||||
value-serializer: org.apache.kafka.common.serialization.StringSerializer
|
||||
acks: all
|
||||
retries: 3
|
||||
properties:
|
||||
connections.max.idle.ms: 10000
|
||||
request.timeout.ms: 5000
|
||||
|
||||
Reference in New Issue
Block a user