배치 아규먼트 적용
This commit is contained in:
parent
e2f164d357
commit
f8a194edd0
@ -2,6 +2,7 @@ package com.interplug.qcast.batch;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.batch.core.Job;
|
||||
import org.springframework.batch.core.JobParameters;
|
||||
import org.springframework.batch.core.JobParametersBuilder;
|
||||
@ -10,11 +11,11 @@ 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.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@ -23,6 +24,9 @@ public class JobLauncherController {
|
||||
|
||||
private final JobLauncher jobLauncher;
|
||||
|
||||
@Value("${qsp.master-admin-user-batch-url}")
|
||||
private String qspInterfaceUrl;
|
||||
|
||||
/**
|
||||
* 특정 Job을 매핑으로 실행하는 메소드
|
||||
*
|
||||
@ -34,43 +38,23 @@ public class JobLauncherController {
|
||||
* @throws JobRestartException
|
||||
*/
|
||||
@GetMapping("/batch/job/{jobName}") // Path Variable로 jobName을 받음
|
||||
public String launchJob(@PathVariable String jobName) throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException, JobParametersInvalidException, JobRestartException {
|
||||
public String launchJob(@PathVariable String jobName)
|
||||
throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException,
|
||||
JobParametersInvalidException,
|
||||
JobRestartException {
|
||||
|
||||
Job job = jobs.get(jobName);
|
||||
if (job == null) {
|
||||
return "Job " + jobName + " not found";
|
||||
}
|
||||
System.out.println("scheduler==========" + System.getProperty("spring.profiles.scheduler"));
|
||||
|
||||
JobParameters jobParameters = new JobParametersBuilder().addString("jobName", jobName)
|
||||
.addDate("time", new Date()).toJobParameters();
|
||||
|
||||
jobLauncher.run(job, jobParameters);
|
||||
|
||||
return "Job " + jobName + " started";
|
||||
}
|
||||
|
||||
/**
|
||||
* 스케줄러로 Job을 실행하는 메소드
|
||||
*
|
||||
* @return
|
||||
* @throws JobInstanceAlreadyCompleteException
|
||||
* @throws JobExecutionAlreadyRunningException
|
||||
* @throws JobParametersInvalidException
|
||||
* @throws JobRestartException
|
||||
*/
|
||||
@Scheduled(cron = "0 55 23 * * *")
|
||||
public String scheduleJobLauncher() throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException, JobParametersInvalidException, JobRestartException {
|
||||
|
||||
String jobName = "sampleOtherJob";
|
||||
Job job = jobs.get(jobName);
|
||||
if (job == null) {
|
||||
return "Job " + jobName + " not found";
|
||||
}
|
||||
|
||||
JobParameters jobParameters = new JobParametersBuilder().addString("jobName", jobName)
|
||||
.addDate("time", new Date()).toJobParameters();
|
||||
JobParameters jobParameters =
|
||||
new JobParametersBuilder()
|
||||
.addString("jobName", jobName)
|
||||
.addDate("time", new Date())
|
||||
.toJobParameters();
|
||||
|
||||
jobLauncher.run(job, jobParameters);
|
||||
|
||||
@ -88,19 +72,23 @@ public class JobLauncherController {
|
||||
*/
|
||||
// @Scheduled(cron = "*/5 * * * * *")
|
||||
@Scheduled(cron = "0 55 23 * * *")
|
||||
public String storeAdditionalInfoJob() throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException, JobParametersInvalidException, JobRestartException {
|
||||
public String storeAdditionalInfoJob()
|
||||
throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException,
|
||||
JobParametersInvalidException,
|
||||
JobRestartException {
|
||||
|
||||
String jobName = "storeAdditionalJob";
|
||||
Job job = jobs.get(jobName);
|
||||
if (job == null) {
|
||||
return "Job " + jobName + " not found";
|
||||
}
|
||||
JobParameters jobParameters =
|
||||
new JobParametersBuilder().addDate("time", new Date()).toJobParameters();
|
||||
|
||||
jobLauncher.run(job, jobParameters);
|
||||
if ("Y".equals(System.getProperty("spring.profiles.scheduler"))) {
|
||||
JobParameters jobParameters =
|
||||
new JobParametersBuilder().addDate("time", new Date()).toJobParameters();
|
||||
|
||||
jobLauncher.run(job, jobParameters);
|
||||
}
|
||||
return "OK";
|
||||
}
|
||||
|
||||
@ -113,9 +101,12 @@ public class JobLauncherController {
|
||||
* @throws JobParametersInvalidException
|
||||
* @throws JobRestartException
|
||||
*/
|
||||
@Scheduled(cron = "0 0 0 * * *")
|
||||
public String materialJob() throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException, JobParametersInvalidException, JobRestartException {
|
||||
@Scheduled(cron = "0 30 02 * * *")
|
||||
public String materialJob()
|
||||
throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException,
|
||||
JobParametersInvalidException,
|
||||
JobRestartException {
|
||||
|
||||
String jobName = "materialJob";
|
||||
Job job = jobs.get(jobName);
|
||||
@ -123,11 +114,12 @@ public class JobLauncherController {
|
||||
return "Job " + jobName + " not found";
|
||||
}
|
||||
|
||||
JobParameters jobParameters =
|
||||
new JobParametersBuilder().addDate("time", new Date()).toJobParameters();
|
||||
|
||||
jobLauncher.run(job, jobParameters);
|
||||
if ("Y".equals(System.getProperty("spring.profiles.scheduler"))) {
|
||||
JobParameters jobParameters =
|
||||
new JobParametersBuilder().addDate("time", new Date()).toJobParameters();
|
||||
|
||||
jobLauncher.run(job, jobParameters);
|
||||
}
|
||||
return "OK";
|
||||
}
|
||||
|
||||
@ -140,9 +132,12 @@ public class JobLauncherController {
|
||||
* @throws JobParametersInvalidException
|
||||
* @throws JobRestartException
|
||||
*/
|
||||
@Scheduled(cron = "0 0 0 * * *")
|
||||
public String bomJob() throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException, JobParametersInvalidException, JobRestartException {
|
||||
@Scheduled(cron = "0 40 02 * * *")
|
||||
public String bomJob()
|
||||
throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException,
|
||||
JobParametersInvalidException,
|
||||
JobRestartException {
|
||||
|
||||
String jobName = "bomJob";
|
||||
Job job = jobs.get(jobName);
|
||||
@ -150,10 +145,12 @@ public class JobLauncherController {
|
||||
return "Job " + jobName + " not found";
|
||||
}
|
||||
|
||||
JobParameters jobParameters =
|
||||
new JobParametersBuilder().addDate("time", new Date()).toJobParameters();
|
||||
if ("Y".equals(System.getProperty("spring.profiles.scheduler"))) {
|
||||
JobParameters jobParameters =
|
||||
new JobParametersBuilder().addDate("time", new Date()).toJobParameters();
|
||||
|
||||
jobLauncher.run(job, jobParameters);
|
||||
jobLauncher.run(job, jobParameters);
|
||||
}
|
||||
|
||||
return "OK";
|
||||
}
|
||||
@ -167,9 +164,12 @@ public class JobLauncherController {
|
||||
* @throws JobParametersInvalidException
|
||||
* @throws JobRestartException
|
||||
*/
|
||||
@Scheduled(cron = "0 0 0 * * *")
|
||||
public String businessChargerJob() throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException, JobParametersInvalidException, JobRestartException {
|
||||
@Scheduled(cron = "0 40 03 * * *")
|
||||
public String businessChargerJob()
|
||||
throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException,
|
||||
JobParametersInvalidException,
|
||||
JobRestartException {
|
||||
|
||||
String jobName = "businessChargerJob";
|
||||
Job job = jobs.get(jobName);
|
||||
@ -177,10 +177,12 @@ public class JobLauncherController {
|
||||
return "Job " + jobName + " not found";
|
||||
}
|
||||
|
||||
JobParameters jobParameters =
|
||||
new JobParametersBuilder().addDate("time", new Date()).toJobParameters();
|
||||
if ("Y".equals(System.getProperty("spring.profiles.scheduler"))) {
|
||||
JobParameters jobParameters =
|
||||
new JobParametersBuilder().addDate("time", new Date()).toJobParameters();
|
||||
|
||||
jobLauncher.run(job, jobParameters);
|
||||
jobLauncher.run(job, jobParameters);
|
||||
}
|
||||
|
||||
return "OK";
|
||||
}
|
||||
@ -194,9 +196,12 @@ public class JobLauncherController {
|
||||
* @throws JobParametersInvalidException
|
||||
* @throws JobRestartException
|
||||
*/
|
||||
@Scheduled(cron = "0 0 0 * * *")
|
||||
public String adminUserJob() throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException, JobParametersInvalidException, JobRestartException {
|
||||
@Scheduled(cron = "0 0 01 * * *")
|
||||
public String adminUserJob()
|
||||
throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException,
|
||||
JobParametersInvalidException,
|
||||
JobRestartException {
|
||||
|
||||
String jobName = "adminUserJob";
|
||||
Job job = jobs.get(jobName);
|
||||
@ -204,10 +209,12 @@ public class JobLauncherController {
|
||||
return "Job " + jobName + " not found";
|
||||
}
|
||||
|
||||
JobParameters jobParameters =
|
||||
new JobParametersBuilder().addDate("time", new Date()).toJobParameters();
|
||||
if ("Y".equals(System.getProperty("spring.profiles.scheduler"))) {
|
||||
JobParameters jobParameters =
|
||||
new JobParametersBuilder().addDate("time", new Date()).toJobParameters();
|
||||
|
||||
jobLauncher.run(job, jobParameters);
|
||||
jobLauncher.run(job, jobParameters);
|
||||
}
|
||||
|
||||
return "OK";
|
||||
}
|
||||
@ -222,8 +229,11 @@ public class JobLauncherController {
|
||||
* @throws JobRestartException
|
||||
*/
|
||||
@Scheduled(cron = "0 0 0 * * *")
|
||||
public String priceJob() throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException, JobParametersInvalidException, JobRestartException {
|
||||
public String priceJob()
|
||||
throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException,
|
||||
JobParametersInvalidException,
|
||||
JobRestartException {
|
||||
|
||||
String jobName = "priceJob";
|
||||
Job job = jobs.get(jobName);
|
||||
@ -231,10 +241,12 @@ public class JobLauncherController {
|
||||
return "Job " + jobName + " not found";
|
||||
}
|
||||
|
||||
JobParameters jobParameters =
|
||||
new JobParametersBuilder().addDate("time", new Date()).toJobParameters();
|
||||
if ("Y".equals(System.getProperty("spring.profiles.scheduler"))) {
|
||||
JobParameters jobParameters =
|
||||
new JobParametersBuilder().addDate("time", new Date()).toJobParameters();
|
||||
|
||||
jobLauncher.run(job, jobParameters);
|
||||
jobLauncher.run(job, jobParameters);
|
||||
}
|
||||
|
||||
return "OK";
|
||||
}
|
||||
@ -248,9 +260,12 @@ public class JobLauncherController {
|
||||
* @throws JobParametersInvalidException
|
||||
* @throws JobRestartException
|
||||
*/
|
||||
@Scheduled(cron = "0 0 0 * * *")
|
||||
public String commonCodeJob() throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException, JobParametersInvalidException, JobRestartException {
|
||||
@Scheduled(cron = "0 10 03 * * *")
|
||||
public String commonCodeJob()
|
||||
throws JobInstanceAlreadyCompleteException,
|
||||
JobExecutionAlreadyRunningException,
|
||||
JobParametersInvalidException,
|
||||
JobRestartException {
|
||||
|
||||
String jobName = "commonCodeJob";
|
||||
Job job = jobs.get(jobName);
|
||||
@ -258,10 +273,12 @@ public class JobLauncherController {
|
||||
return "Job " + jobName + " not found";
|
||||
}
|
||||
|
||||
JobParameters jobParameters =
|
||||
new JobParametersBuilder().addDate("time", new Date()).toJobParameters();
|
||||
if ("Y".equals(System.getProperty("spring.profiles.scheduler"))) {
|
||||
JobParameters jobParameters =
|
||||
new JobParametersBuilder().addDate("time", new Date()).toJobParameters();
|
||||
|
||||
jobLauncher.run(job, jobParameters);
|
||||
jobLauncher.run(job, jobParameters);
|
||||
}
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user