commit
This commit is contained in:
@@ -12,6 +12,7 @@ import org.springframework.scheduling.quartz.QuartzJobBean;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Quartz 작업을 실행하는 Spring Batch Job 실행기 클래스입니다.
|
||||
@@ -31,13 +32,16 @@ import lombok.RequiredArgsConstructor;
|
||||
* @see JobLauncher
|
||||
* @see JobRegistry
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class QuartzJobLauncher extends QuartzJobBean {
|
||||
|
||||
private static final String JOB_PARAMETERS_INSTANCE_KEY = "InstanceId";
|
||||
private static final String JOB_PARAMETERS_TIMESTAMP_KEY = "timestamp";
|
||||
|
||||
private final JobLauncher jobLauncher;
|
||||
private final JobRegistry jobRegistry;
|
||||
|
||||
private String jobName;
|
||||
|
||||
public void setJobName(String jobName) {
|
||||
@@ -61,11 +65,13 @@ public class QuartzJobLauncher extends QuartzJobBean {
|
||||
try {
|
||||
Job job = jobRegistry.getJob(jobName);
|
||||
JobParameters params = new JobParametersBuilder()
|
||||
.addString("JobID", String.valueOf(System.currentTimeMillis()))
|
||||
.addString(JOB_PARAMETERS_INSTANCE_KEY, context.getScheduler().getSchedulerInstanceId())
|
||||
.addLong(JOB_PARAMETERS_TIMESTAMP_KEY, System.currentTimeMillis())
|
||||
.toJobParameters();
|
||||
jobLauncher.run(job, params);
|
||||
} catch (Exception e) {
|
||||
throw new JobExecutionException(e);
|
||||
log.error("job execution exception! - {}", e.getCause());
|
||||
throw new JobExecutionException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user