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