commit
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.spring.infra.quartz;
|
||||
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.springframework.batch.core.Job;
|
||||
@@ -42,11 +43,6 @@ public class QuartzJobLauncher extends QuartzJobBean {
|
||||
|
||||
private final JobLauncher jobLauncher;
|
||||
private final JobRegistry jobRegistry;
|
||||
private String jobName;
|
||||
|
||||
public void setJobName(String jobName) {
|
||||
this.jobName = jobName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Quartz 스케줄러에 의해 호출되는 메소드로, 실제 Job을 실행합니다.
|
||||
@@ -62,6 +58,9 @@ public class QuartzJobLauncher extends QuartzJobBean {
|
||||
*/
|
||||
@Override
|
||||
protected void executeInternal(@NonNull JobExecutionContext context) throws JobExecutionException {
|
||||
JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
|
||||
String jobName = jobDataMap.getString("jobName");
|
||||
|
||||
try {
|
||||
Job job = jobRegistry.getJob(jobName);
|
||||
JobParameters params = new JobParametersBuilder()
|
||||
@@ -70,7 +69,7 @@ public class QuartzJobLauncher extends QuartzJobBean {
|
||||
.toJobParameters();
|
||||
jobLauncher.run(job, params);
|
||||
} catch (Exception e) {
|
||||
log.error("job execution exception! - {}", e.getCause());
|
||||
log.error("Job execution exception! - {}", e.getMessage(), e);
|
||||
throw new JobExecutionException();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user