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/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); } 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) {