From 4e1c054ce369e33cfb8e5aebc2e9b8eca26e6a6d Mon Sep 17 00:00:00 2001 From: dongkyeomjang Date: Sat, 23 Nov 2024 18:47:03 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Refactor/#117=20-=20=EC=9D=B4?= =?UTF-8?q?=EB=B2=A4=ED=8A=B8=20Consume=20=EB=A1=9C=EC=A7=81=EC=97=90=20Jo?= =?UTF-8?q?b=20=EC=82=AD=EC=A0=9C=20=EB=A1=9C=EC=A7=81=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/daon/onjung/core/domain/ScheduledEventJob.java | 2 ++ .../consumer/EventSchedulerConsumerV1Controller.java | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/src/main/java/com/daon/onjung/core/domain/ScheduledEventJob.java b/src/main/java/com/daon/onjung/core/domain/ScheduledEventJob.java index 9910767..9d14d15 100644 --- a/src/main/java/com/daon/onjung/core/domain/ScheduledEventJob.java +++ b/src/main/java/com/daon/onjung/core/domain/ScheduledEventJob.java @@ -6,6 +6,7 @@ import lombok.NoArgsConstructor; import org.springframework.data.annotation.Id; import org.springframework.data.redis.core.RedisHash; +import org.springframework.data.redis.core.index.Indexed; import java.time.LocalDateTime; import java.util.UUID; @@ -18,6 +19,7 @@ public class ScheduledEventJob { @Id private String jobId; + @Indexed private Long eventId; private LocalDateTime scheduledTime; diff --git a/src/main/java/com/daon/onjung/event/application/controller/consumer/EventSchedulerConsumerV1Controller.java b/src/main/java/com/daon/onjung/event/application/controller/consumer/EventSchedulerConsumerV1Controller.java index 0430c2a..be4d5ce 100644 --- a/src/main/java/com/daon/onjung/event/application/controller/consumer/EventSchedulerConsumerV1Controller.java +++ b/src/main/java/com/daon/onjung/event/application/controller/consumer/EventSchedulerConsumerV1Controller.java @@ -1,20 +1,29 @@ package com.daon.onjung.event.application.controller.consumer; +import com.daon.onjung.core.repository.redis.ScheduledEventJobRepository; import com.daon.onjung.event.application.usecase.ProcessCompletedEventUseCase; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.quartz.Job; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; @RequiredArgsConstructor +@Slf4j public class EventSchedulerConsumerV1Controller implements Job { private final ProcessCompletedEventUseCase processCompletedEventUseCase; + private final ScheduledEventJobRepository scheduledEventJobRepository; @Override public void execute(JobExecutionContext context) throws JobExecutionException { + // JobDataMap을 통해 eventId를 가져온다. Long eventId = context.getJobDetail().getJobDataMap().getLong("eventId"); + // eventId를 통해 ScheduledEventJob을 삭제 + scheduledEventJobRepository.deleteById(eventId.toString()); + log.info("ScheduledEventJob 삭제 완료. eventId: {}", eventId); + processCompletedEventUseCase.execute(eventId); } }