-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from kusitms-28th-Meetup-E/feat/batch
feat(#1) : scheduled cron
- Loading branch information
Showing
3 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
src/main/java/gwangjang/server/KeywordServiceApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/java/gwangjang/server/domain/morpheme/presentation/JobController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package gwangjang.server.domain.morpheme.presentation; | ||
|
||
import org.springframework.batch.core.Job; | ||
import org.springframework.batch.core.JobExecution; | ||
import org.springframework.batch.core.JobParameters; | ||
import org.springframework.batch.core.launch.JobLauncher; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/api") | ||
public class JobController { | ||
|
||
private final JobLauncher jobLauncher; | ||
private final Job apiJob; // Inject the job bean you want to execute | ||
|
||
@Autowired | ||
public JobController(JobLauncher jobLauncher, Job apiJob) { | ||
this.jobLauncher = jobLauncher; | ||
this.apiJob = apiJob; | ||
} | ||
|
||
@GetMapping("/runJob") | ||
public String runJob() throws Exception { | ||
JobExecution jobExecution = jobLauncher.run(apiJob, new JobParameters()); | ||
return "Job Execution Status: " + jobExecution.getStatus(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters