Skip to content

Commit

Permalink
♻️refactor: Kafka 테스트용 Consumer 주석 처리 및 전송 내용 주석 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
seheonnn committed May 13, 2024
1 parent 6c2acb6 commit d69073b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
package com.waither.weatherservice.kafka;

import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Component
@RequiredArgsConstructor
public class Consumer {

@KafkaListener(topics = "${spring.kafka.template.topic}", groupId = "${spring.kafka.consumer.group-id}")
public void dailyWeatherConsume(String message) {

log.info("Consumer Test ========================== ");
log.info("[*] Consumer Message {} ", message);
}
}
// 테스트용 Consumer
// @Slf4j
// @Component
// @RequiredArgsConstructor
// public class Consumer {
//
// @KafkaListener(topics = "${spring.kafka.template.topic}", groupId = "${spring.kafka.consumer.group-id}")
// public void dailyWeatherConsume(String message) {
//
// log.info("Consumer Test ========================== ");
// log.info("[*] Consumer Message {} ", message);
// }
// }
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Producer {
@Value("${spring.kafka.template.topic}")
private String topic;

public void dailyWeatherProduceMessage(String message) {
public void produceMessage(String message) {
log.info("[*] Producer Message : {}", message);
kafkaTemplate.send(topic, message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public void createExpectedWeather(
.expectedSky(expectedSkyList)
.build();

// TODO 조회 테스트 후 삭제 예정
ExpectedWeather save = expectedWeatherRepository.save(expectedWeather);
log.info("[*] 예상 기후 : {}", save);
}
Expand Down Expand Up @@ -97,7 +96,8 @@ public void createDailyWeather(int nx,

// DailyWeatherKafkaMessage kafkaMessage = DailyWeatherKafkaMessage.from(dailyWeather);

producer.dailyWeatherProduceMessage(wsd);
// 바람 세기 Kafka 전송
producer.produceMessage(wsd);

// DailyWeather save = dailyWeatherRepository.save(dailyWeather);
log.info("[*] 하루 온도 : {}", dailyWeather);
Expand All @@ -117,7 +117,6 @@ public void createDisasterMsg(String location) throws URISyntaxException, IOExce
.message(msg)
.build();

// TODO 조회 테스트 후 삭제 예정
DisasterMessage save = disasterMessageRepository.save(disasterMessage);
log.info("[*] 재난 문자 : {}", save);
}
Expand Down

0 comments on commit d69073b

Please sign in to comment.