-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMysqlBatchController.java
More file actions
41 lines (34 loc) · 1.65 KB
/
MysqlBatchController.java
File metadata and controls
41 lines (34 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.sangchu.preprocess.etl.controller;
import com.sangchu.preprocess.scheduler.PreProcessScheduler;
import lombok.RequiredArgsConstructor;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.JobParametersInvalidException;
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.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/test")
@RequiredArgsConstructor
public class MysqlBatchController {
private final JobLauncher jobLauncher;
private final Job mysqlJob;
private final PreProcessScheduler preProcessScheduler;
@PostMapping("/import/mysql")
public String runImportMysqlJob() throws JobInstanceAlreadyCompleteException, JobExecutionAlreadyRunningException, JobParametersInvalidException, JobRestartException {
JobParameters jobParameters = new JobParametersBuilder()
.addLong("time", System.currentTimeMillis())
.toJobParameters();
jobLauncher.run(mysqlJob, jobParameters);
return "csv -> mysql 작업";
}
@PostMapping("/scheduler")
public void runScheduler() throws Exception {
preProcessScheduler.scheduler();
}
}