-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- BatchApplication.java: 배치 스케줄링 및 @EnableBatchProcessing 어노테이션 이동. - DeleteExpiredEbookJobConfiguration.java: @EnableBatchProcessing 어노테이션 이동 및 쿼리문 내 별명 수정. 리턴 구문 단순화. - BatchScheduler.java: 만료된 전자책 삭제 Job이 매일 0시 0분 0초에 수행되도록 스케줄링 설정. - app-batch\src\main\resources\application.yaml: 배치 앱 실행 시 최초 수행을 막도록 batch.job.enabled: false 적용. 잘못된 프로파일명 수정.
- Loading branch information
Showing
4 changed files
with
40 additions
and
9 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
app-batch/src/main/java/com/shacomiro/nesonnechek/batch/BatchApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
app-batch/src/main/java/com/shacomiro/nesonnechek/batch/scheduler/BatchScheduler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.shacomiro.nesonnechek.batch.scheduler; | ||
|
||
import org.springframework.batch.core.JobParametersBuilder; | ||
import org.springframework.batch.core.JobParametersInvalidException; | ||
import org.springframework.batch.core.launch.JobLauncher; | ||
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException; | ||
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException; | ||
import org.springframework.batch.core.repository.JobRestartException; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
|
||
import com.shacomiro.nesonnechek.batch.job.DeleteExpiredEbookJobConfiguration; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class BatchScheduler { | ||
private final JobLauncher jobLauncher; | ||
private final DeleteExpiredEbookJobConfiguration deleteExpiredEbookJobConfiguration; | ||
|
||
@Scheduled(cron = "0 0 0 * * *") | ||
public void runDeleteExpiredEbookJob() throws | ||
JobInstanceAlreadyCompleteException, | ||
JobExecutionAlreadyRunningException, | ||
JobParametersInvalidException, | ||
JobRestartException { | ||
jobLauncher.run(deleteExpiredEbookJobConfiguration.deleteExpiredEbookJob(), | ||
new JobParametersBuilder().addLong("time", System.currentTimeMillis()).toJobParameters()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters