-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 매일 3시 15분에 최대 500개의 로그 삭제
- Loading branch information
Showing
3 changed files
with
40 additions
and
4 deletions.
There are no files selected for viewing
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
36 changes: 36 additions & 0 deletions
36
src/main/java/com/kusitms/jipbap/event/scheduler/ClearJobScheduler.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,36 @@ | ||
package com.kusitms.jipbap.event.scheduler; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.batch.core.Job; | ||
import org.springframework.batch.core.JobParameter; | ||
import org.springframework.batch.core.JobParameters; | ||
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 java.util.Collections; | ||
|
||
/** | ||
* 스케줄러를 통해서 Job 실행 | ||
*/ | ||
@Component | ||
@RequiredArgsConstructor | ||
public class ClearJobScheduler { | ||
|
||
private final Job eventLogClearJob; | ||
private final JobLauncher jobLauncher; // 스케줄링을 활용하여 Job 실행 | ||
|
||
@Scheduled(cron = "0 3 15 * * *") // 매일 특정 시간(3시 15분)에 실행 | ||
public void testJobRun() throws JobInstanceAlreadyCompleteException, JobExecutionAlreadyRunningException, JobParametersInvalidException, JobRestartException { | ||
|
||
JobParameters jobParameters = new JobParameters( | ||
Collections.singletonMap("requestTime", new JobParameter(System.currentTimeMillis(), Long.class)) | ||
); | ||
|
||
jobLauncher.run(eventLogClearJob, jobParameters); | ||
} | ||
} |
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