Skip to content

Commit

Permalink
🔨 Refactor/#117 - 이벤트 Consume 로직에 Job 삭제 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
dongkyeomjang committed Nov 23, 2024
1 parent 6785dff commit 4e1c054
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -18,6 +19,7 @@ public class ScheduledEventJob {
@Id
private String jobId;

@Indexed
private Long eventId;

private LocalDateTime scheduledTime;
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit 4e1c054

Please sign in to comment.