This is a job scheduler implemented by springboot,quartz and json MockDB.
- springboot for rest api,quartz for job scheduler, json operation for Mock DB
- Eligible to Create/Read/Update/Delete jobs to run and restfuly api provided.
- Supports one time execution and repetitive executions triggered at a fixed interval, i.e. 10 seconds.
- Use JSON File as DB-Mock to persist jobs.
- The application ultilize quartz thread pool to scale to thousands of jobs and many workers.
- dockerized running available
- Create a job:
http://hostip:8080/api/addjob
POST
{
"jobName": "job1",
"jobDesc": "job1 task created!",
"interval": 5
}
interval: 0 ==> one time job
interval: positive integer ==> repetitive job,
-
Get job list:
http://hostip:8080/api/getalljobs
GET
-
Query a job by job name:
http://hostip:8080/api/getjob/{jobName}
GET
-
Update a job(reschedule job by new interval and change job description):
Api Url:http://hostip:8080/api/updatejob
POST
{
"jobName": "job1",
"jobDesc": "job1 task updated",
"interval": 10
}
interval: 0 ==> one time job
interval: positive integer ==> repetitive job
-
Delete a job:
http://hostip:8080/api/deljob/{jobName}
GET
-
Pause a job:
http://hostip:8080/api/pausejob/{jobName}
GET
-
Resume a job:
http://hostip:8080/api/resumejob/{jobName}
GET
-
Pause all jobs:
http://hostip:8080/api/pauseall
GET
-
Resume all jobs:
http://hostip:8080/api/resumeall
GET
-
General Response Example
{
"code": 200,
"message": "SUCCESS",
"data": {
"job2": "{\"interval\":5,\"jobDesc\":\"job2 updated !\",\"jobName\":\"job2\",\"status\":\"running\"}",
"job1": "{\"interval\":2,\"jobDesc\":\"job1 start!\",\"jobName\":\"job1\",\"status\":\"running\"}"
}
}
- cd to project root dir and run below commands:
docker build -t yuanbest/job-scheduler-test .
docker run -dt -p 8080:8080 yuanbest/job-scheduler-test
Then you have build docker image and ran the container.