This commit is contained in:
mindol1004
2024-09-25 10:32:37 +09:00
parent 9d1079fcbd
commit 4f3d7e659b
35 changed files with 549 additions and 269 deletions

View File

@@ -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();
}
}