Skip to content

Quartz Scheduling

ArchForge integrates Spring Quartz to provide a reflective, admin-configurable scheduling system. Jobs are defined by a bean name, method name, and optional method parameters, and can be managed directly from the admin panel.

Features

  • Reflective invocation — Define a job as beanName.methodName(params) without writing a new Quartz job class.
  • Full CRUD — Create, update, delete, pause, resume, and trigger jobs immediately.
  • Execution logs — Each run is recorded with status, duration, start/finish time, and error messages.
  • Cron validation — Built-in endpoint to validate cron expressions before saving.
  • Concurrency control — Jobs can be marked concurrent or non-concurrent.

Data Model — SysQuartzJob (sys_quartz_job)

FieldTypeDescription
idLongPrimary key
jobNameStringJob name
jobGroupStringJob group
descriptionStringHuman-readable description
beanNameStringTarget Spring bean name
methodNameStringMethod to invoke on the bean
methodParamsStringOptional parameter string
cronStringCron expression
misfirePolicyShortMisfire policy code
concurrentBooleanWhether the job can run concurrently
statusShort1 paused, 2 running

Data Model — SysQuartzLog (sys_quartz_log)

FieldTypeDescription
idLongPrimary key
jobIdLongReference to the job
jobNameStringJob name
jobGroupStringJob group
beanNameStringTarget bean
methodNameStringMethod invoked
methodParamsStringParameters used
statusShort0 success, 1 failure
errorMessageStringError message if failed
durationMsLongExecution duration in milliseconds
startedAtDateTimeStart time
finishedAtDateTimeFinish time

API Endpoints

MethodEndpointDescription
POST/quartz/listQuery job list with pagination
POST/quartz/addCreate a new job
PUT/quartz/update/{id}Update a job
DELETE/quartz/delete/{id}Delete a job
POST/quartz/pause/{id}Pause a job
POST/quartz/resume/{id}Resume a job
POST/quartz/run/{id}Run a job immediately
POST/quartz/log/listQuery execution logs for a job
POST/quartz/validate-cronValidate a cron expression

Example Job Definition

json
{
  "jobName": "cleanTempFiles",
  "jobGroup": "system",
  "description": "Clean temp files every day",
  "beanName": "fileCleanupService",
  "methodName": "clean",
  "methodParams": "30",
  "cron": "0 0 2 * * ?",
  "concurrent": false,
  "status": 2
}

How It Works

  1. The admin UI sends the job definition to QuartzJobController.
  2. QuartzJobService persists the SysQuartzJob record.
  3. The QuartzReflectionJob reads the bean name, method, and parameters and invokes the target Spring bean.
  4. After each execution, a SysQuartzLog record is created with the result.

Security Notes

  • All management endpoints require the ADMIN role.
  • The reflective invocation is restricted to Spring beans registered in the application context.

Released under the MIT License.