From 8d4bd7495f165ea287b5d812dc79c51837d06cd5 Mon Sep 17 00:00:00 2001 From: seheonnn Date: Fri, 5 Jul 2024 17:59:07 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20fix:=20=EA=B8=B0=EC=83=81?= =?UTF-8?q?=ED=8A=B9=EB=B3=B4=20=EB=B0=B0=EC=B9=98=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weatherservice/batch/BatchConfig.java | 19 +++++++++++++++++++ .../weatherservice/kafka/Producer.java | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/weather-service/src/main/java/com/waither/weatherservice/batch/BatchConfig.java b/weather-service/src/main/java/com/waither/weatherservice/batch/BatchConfig.java index 5b55607c..5c72083f 100644 --- a/weather-service/src/main/java/com/waither/weatherservice/batch/BatchConfig.java +++ b/weather-service/src/main/java/com/waither/weatherservice/batch/BatchConfig.java @@ -59,4 +59,23 @@ public Step expectedWeatherStep() { public Tasklet expectedWeatherTasklet() { return new ExpectedWeatherTasklet(weatherService); } + + @Bean + public Job weatherAdvisoryJob() { + return new JobBuilder("weatherAdvisoryJob", jobRepository) + .start(weatherAdvisoryStep()) + .build(); + } + + @Bean + public Step weatherAdvisoryStep() { + return new StepBuilder("weatherAdvisoryStep", jobRepository) + .tasklet(weatherAdvisoryTasklet(), transactionManager) + .build(); + } + + @Bean + public Tasklet weatherAdvisoryTasklet() { + return new WeatherAdvisoryTasklet(weatherService); + } } diff --git a/weather-service/src/main/java/com/waither/weatherservice/kafka/Producer.java b/weather-service/src/main/java/com/waither/weatherservice/kafka/Producer.java index df058477..79469436 100644 --- a/weather-service/src/main/java/com/waither/weatherservice/kafka/Producer.java +++ b/weather-service/src/main/java/com/waither/weatherservice/kafka/Producer.java @@ -22,7 +22,7 @@ public void produceMessage(String topic, Object message) { kafkaTemplate.send(topic, message); - CompletableFuture> future = kafkaTemplate.send(topic, "weather-key", message); + CompletableFuture> future = kafkaTemplate.send(topic, message); future.whenComplete(((result, throwable) -> { if (throwable == null) { From c8d0199ad4f8727a5d7ab7393514fae7f628b808 Mon Sep 17 00:00:00 2001 From: seheonnn Date: Fri, 5 Jul 2024 18:03:19 +0900 Subject: [PATCH 2/2] =?UTF-8?q?:bug:=20fix:=20=EB=B0=B0=EC=B9=98=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20=EC=98=A4=EB=A5=98=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/waither/weatherservice/batch/BatchScheduler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/weather-service/src/main/java/com/waither/weatherservice/batch/BatchScheduler.java b/weather-service/src/main/java/com/waither/weatherservice/batch/BatchScheduler.java index 37b055a6..685ff09e 100644 --- a/weather-service/src/main/java/com/waither/weatherservice/batch/BatchScheduler.java +++ b/weather-service/src/main/java/com/waither/weatherservice/batch/BatchScheduler.java @@ -21,7 +21,7 @@ public class BatchScheduler { private final JobLauncher jobLauncher; private final Job dailyWeatherJob; private final Job expectedWeatherJob; - private final Job weatherAdvisoryTasklet; + private final Job weatherAdvisoryJob; @Scheduled(cron = "0 0 2,5,8,11,14,17,20,23 * * *") // 3시간마다 public void runDailyWeatherJob() { @@ -59,7 +59,7 @@ public void runWeatherAdvisoryJob() { .addLong("executedTime", System.currentTimeMillis()) .toJobParameters(); - jobLauncher.run(weatherAdvisoryTasklet, jobParameters); + jobLauncher.run(weatherAdvisoryJob, jobParameters); } catch (JobExecutionException e) { log.error("Error executing expectedWeatherJob: ", e); }