-
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.
YEL-214 [feat] lunch event spring batch, scheduler 연결
- Loading branch information
1 parent
926afde
commit f2b6438
Showing
8 changed files
with
110 additions
and
21 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
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
4 changes: 0 additions & 4 deletions
4
src/main/java/com/yello/server/infrastructure/batch/ChunkProcessor.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
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
49 changes: 49 additions & 0 deletions
49
src/main/java/com/yello/server/infrastructure/scheduler/EventScheduler.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,49 @@ | ||
package com.yello.server.infrastructure.scheduler; | ||
|
||
|
||
import com.yello.server.infrastructure.batch.JobConfiguration; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.batch.core.JobParameter; | ||
import org.springframework.batch.core.JobParameters; | ||
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.JobRepository; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.PlatformTransactionManager; | ||
|
||
import java.util.Date; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class EventScheduler { | ||
|
||
private final JobLauncher jobLauncher; | ||
private final JobConfiguration jobConfiguration; | ||
private final JobRepository jobRepository; | ||
private final PlatformTransactionManager transactionManager; | ||
|
||
@Scheduled(cron="0 0 12 * * ?") | ||
public void lunchEventRunJob() { | ||
|
||
//JobParamter의 역할은 반복해서 실행되는 Job의 유일한 ID임, 동일한 값이 세팅되면 두번째부터 실행안됨) | ||
JobParameters jobParameters = new JobParametersBuilder() | ||
.addString("uuid", UUID.randomUUID().toString()) | ||
.toJobParameters(); | ||
|
||
try { | ||
jobLauncher.run(jobConfiguration.lunchEventJob(jobRepository, transactionManager), jobParameters); | ||
} catch (JobExecutionAlreadyRunningException | JobInstanceAlreadyCompleteException | ||
| JobParametersInvalidException | org.springframework.batch.core.repository.JobRestartException e) { | ||
System.out.println(e.getMessage()); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
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