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