From 3a385477cc4d28dfcb3c5d91b0ae336b7b647c4c Mon Sep 17 00:00:00 2001 From: JaeSeo Yang <96044622+psychology50@users.noreply.github.com> Date: Thu, 7 Nov 2024 21:44:47 +0900 Subject: [PATCH] chore: last_message_id job scheuling --- .../scheduler/SpendingNotifyScheduler.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pennyway-batch/src/main/java/kr/co/pennyway/batch/scheduler/SpendingNotifyScheduler.java b/pennyway-batch/src/main/java/kr/co/pennyway/batch/scheduler/SpendingNotifyScheduler.java index a07982f7e..9f2e8e619 100644 --- a/pennyway-batch/src/main/java/kr/co/pennyway/batch/scheduler/SpendingNotifyScheduler.java +++ b/pennyway-batch/src/main/java/kr/co/pennyway/batch/scheduler/SpendingNotifyScheduler.java @@ -13,6 +13,8 @@ import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; +import java.util.concurrent.TimeUnit; + @Slf4j @Component @RequiredArgsConstructor @@ -20,6 +22,7 @@ public class SpendingNotifyScheduler { private final JobLauncher jobLauncher; private final Job dailyNotificationJob; private final Job monthlyNotificationJob; + private final Job lastMessageIdJob; @Scheduled(cron = "0 0 20 * * ?") public void runDailyNotificationJob() { @@ -48,4 +51,18 @@ public void runMonthlyNotificationJob() { log.error("Failed to run monthlyNotificationJob", e); } } + + @Scheduled(fixedRate = 30, timeUnit = TimeUnit.MINUTES) + public void runLastMessageIdJob() { + JobParameters jobParameters = new JobParametersBuilder() + .addLong("time", System.currentTimeMillis()) + .toJobParameters(); + + try { + jobLauncher.run(lastMessageIdJob, jobParameters); + } catch (JobExecutionAlreadyRunningException | JobRestartException + | JobInstanceAlreadyCompleteException | JobParametersInvalidException e) { + log.error("Failed to run lastMessageIdJob", e); + } + } }