Skip to content
Merged

prod #392

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.time.LocalDate;

@Slf4j
@CronJob(cron = "0 0 3 22 10 ?", name = "examNumberGeneratorJob_20251026")
@CronJob(cron = "0 0 8 22 10 ?", name = "examNumberGeneratorJob_20251026")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

cron 표현식을 코드에 하드코딩하면 스케줄 변경 시 코드를 수정하고 다시 배포해야 하는 번거로움이 있습니다. 운영 환경에서는 유연성이 떨어질 수 있습니다.

이 값을 application.yml과 같은 설정 파일로 분리하는 것을 고려해 보세요.

application.yml:

mosu:
  job:
    exam-number-generation-round2:
      cron: "0 0 8 22 10 ?"

그리고 CronJob 어노테이션에서 이 값을 참조하도록 합니다.

@CronJob(cron = "${mosu.job.exam-number-generation-round2.cron}", name = "examNumberGeneratorJob_20251026")

이를 위해서는 QuartzAutoRegisterConfig에서 cron 표현식을 읽을 때 Spring의 Environment를 사용하여 프로퍼티 플레이스홀더(${...})를 해석하도록 수정이 필요할 수 있습니다.

관련하여, 22행의 examDateExamNumberGenerationJobRound1과의 코드 중복도 유사한 방식으로 개선할 수 있습니다. 이렇게 하면 향후 새로운 시험 일정을 추가할 때 더 관리하기 쉬운 구조가 될 것입니다.

@DisallowConcurrentExecution
@RequiredArgsConstructor
public class ExamNumberGenerationJobRound2 implements Job {
Expand Down