Quartz(quartz

quartz 端点提供由 Quartz Scheduler 管理的作业和触发器的信息。

获取已注册的分组

作业和触发器以分组方式进行管理。 要获取已注册作业和触发器分组的列表,请对 /actuator/quartz 发起 GET 请求,如下所示:

$ curl 'http://localhost:8080/actuator/quartz' -i -X GET

返回的响应类似如下:

HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 120

{
  "jobs" : {
    "groups" : [ "samples", "tests" ]
  },
  "triggers" : {
    "groups" : [ "samples", "DEFAULT" ]
  }
}

响应结构

响应包含已注册作业和触发器的分组名称。 下表描述了响应的结构:

Path Type Description

jobs.groups

Array

An array of job group names.

triggers.groups

Array

An array of trigger group names.

获取已注册作业名称

要获取已注册作业名称的列表,请对 /actuator/quartz/jobs 发起 GET 请求,如下所示:

$ curl 'http://localhost:8080/actuator/quartz/jobs' -i -X GET

返回的响应类似如下:

HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 137

{
  "groups" : {
    "samples" : {
      "jobs" : [ "jobOne", "jobTwo" ]
    },
    "tests" : {
      "jobs" : [ "jobThree" ]
    }
  }
}

响应结构

响应包含每个分组下已注册的作业名称。 下表描述了响应的结构:

Path Type Description

groups

Object

Job groups keyed by name.

groups.*.jobs

Array

An array of job names.

获取已注册触发器名称

要获取已注册触发器名称的列表,请对 /actuator/quartz/triggers 发起 GET 请求,如下所示:

$ curl 'http://localhost:8080/actuator/quartz/triggers' -i -X GET

返回的响应类似如下:

HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 229

{
  "groups" : {
    "samples" : {
      "paused" : false,
      "triggers" : [ "3am-weekdays", "every-day", "once-a-week" ]
    },
    "DEFAULT" : {
      "paused" : false,
      "triggers" : [ "every-hour-tue-thu" ]
    }
  }
}

响应结构

响应包含每个分组下已注册的触发器名称。 下表描述了响应的结构:

Path Type Description

groups

Object

Trigger groups keyed by name.

groups.*.paused

Boolean

Whether this trigger group is paused.

groups.*.triggers

Array

An array of trigger names.

获取作业分组概览

要获取某一分组下作业的概览,请对 /actuator/quartz/jobs/{groupName} 发起 GET 请求,如下所示:

$ curl 'http://localhost:8080/actuator/quartz/jobs/samples' -i -X GET

上述示例获取了 samples 分组下作业的摘要。 返回的响应类似如下:

HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 201

{
  "group" : "samples",
  "jobs" : {
    "jobOne" : {
      "className" : "org.springframework.scheduling.quartz.DelegatingJob"
    },
    "jobTwo" : {
      "className" : "org.quartz.Job"
    }
  }
}

响应结构

响应包含指定分组下作业的概览。 下表描述了响应的结构:

Path Type Description

group

String

Name of the group.

jobs

Object

Job details keyed by name.

jobs.*.className

String

Fully qualified name of the job implementation.

获取触发器分组概览

要获取某一分组下触发器的概览,请对 /actuator/quartz/triggers/{groupName} 发起 GET 请求,如下所示:

$ curl 'http://localhost:8080/actuator/quartz/triggers/tests' -i -X GET

上述示例获取了 tests 分组下触发器的摘要。 返回的响应类似如下:

HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 1274

{
  "group" : "tests",
  "paused" : false,
  "triggers" : {
    "cron" : {
      "3am-week" : {
        "previousFireTime" : "2020-12-04T03:00:00.000+00:00",
        "nextFireTime" : "2020-12-07T03:00:00.000+00:00",
        "priority" : 3,
        "expression" : "0 0 3 ? * 1,2,3,4,5",
        "timeZone" : "Europe/Paris"
      }
    },
    "simple" : {
      "every-day" : {
        "nextFireTime" : "2020-12-04T12:00:00.000+00:00",
        "priority" : 7,
        "interval" : 86400000
      }
    },
    "dailyTimeInterval" : {
      "tue-thu" : {
        "priority" : 5,
        "interval" : 3600000,
        "daysOfWeek" : [ 3, 5 ],
        "startTimeOfDay" : "09:00:00",
        "endTimeOfDay" : "18:00:00"
      }
    },
    "calendarInterval" : {
      "once-a-week" : {
        "previousFireTime" : "2020-12-02T14:00:00.000+00:00",
        "nextFireTime" : "2020-12-08T14:00:00.000+00:00",
        "priority" : 5,
        "interval" : 604800000,
        "timeZone" : "Asia/Shanghai"
      }
    },
    "custom" : {
      "once-a-year-custom" : {
        "previousFireTime" : "2020-07-14T16:00:00.000+00:00",
        "nextFireTime" : "2021-07-14T16:00:00.000+00:00",
        "priority" : 10,
        "trigger" : "com.example.CustomTrigger@fdsfsd"
      }
    }
  }
}

响应结构

响应包含指定分组下触发器的概览。 可获得触发器实现的具体细节。 下表描述了响应的结构:

Path Type Description

group

String

Name of the group.

paused

Boolean

Whether the group is paused.

triggers.cron

Object

Cron triggers keyed by name, if any.

triggers.simple

Object

Simple triggers keyed by name, if any.

triggers.dailyTimeInterval

Object

Daily time interval triggers keyed by name, if any.

triggers.calendarInterval

Object

Calendar interval triggers keyed by name, if any.

triggers.custom

Object

Any other triggers keyed by name, if any.

triggers.cron.*.previousFireTime

String

Last time the trigger fired, if any.

triggers.cron.*.nextFireTime

String

Next time at which the Trigger is scheduled to fire, if any.

triggers.cron.*.priority

Number

Priority to use if two triggers have the same scheduled fire time.

triggers.cron.*.expression

String

Cron expression to use.

triggers.cron.*.timeZone

String

Time zone for which the expression will be resolved, if any.

triggers.simple.*.previousFireTime

String

Last time the trigger fired, if any.

triggers.simple.*.nextFireTime

String

Next time at which the Trigger is scheduled to fire, if any.

triggers.simple.*.priority

Number

Priority to use if two triggers have the same scheduled fire time.

triggers.simple.*.interval

Number

Interval, in milliseconds, between two executions.

triggers.dailyTimeInterval.*.previousFireTime

String

Last time the trigger fired, if any.

triggers.dailyTimeInterval.*.nextFireTime

String

Next time at which the Trigger is scheduled to fire, if any.

triggers.dailyTimeInterval.*.priority

Number

Priority to use if two triggers have the same scheduled fire time.

triggers.dailyTimeInterval.*.interval

Number

Interval, in milliseconds, added to the fire time in order to calculate the time of the next trigger repeat.

triggers.dailyTimeInterval.*.daysOfWeek

Array

An array of days of the week upon which to fire.

triggers.dailyTimeInterval.*.startTimeOfDay

String

Time of day to start firing at the given interval, if any.

triggers.dailyTimeInterval.*.endTimeOfDay

String

Time of day to complete firing at the given interval, if any.

triggers.calendarInterval.*.previousFireTime

String

Last time the trigger fired, if any.

triggers.calendarInterval.*.nextFireTime

String

Next time at which the Trigger is scheduled to fire, if any.

triggers.calendarInterval.*.priority

Number

Priority to use if two triggers have the same scheduled fire time.

triggers.calendarInterval.*.interval

Number

Interval, in milliseconds, added to the fire time in order to calculate the time of the next trigger repeat.

triggers.calendarInterval.*.timeZone

String

Time zone within which time calculations will be performed, if any.

triggers.custom.*.previousFireTime

String

Last time the trigger fired, if any.

triggers.custom.*.nextFireTime

String

Next time at which the Trigger is scheduled to fire, if any.

triggers.custom.*.priority

Number

Priority to use if two triggers have the same scheduled fire time.

triggers.custom.*.trigger

String

A toString representation of the custom trigger instance.

获取作业详情

要获取某个作业的详细信息,请对 /actuator/quartz/jobs/{groupName}/{jobName} 发起 GET 请求,如下所示:

$ curl 'http://localhost:8080/actuator/quartz/jobs/samples/jobOne' -i -X GET

上述示例获取了由 samples 分组和 jobOne 名称标识的作业详情。 返回的响应类似如下:

HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 609

{
  "group" : "samples",
  "name" : "jobOne",
  "description" : "A sample job",
  "className" : "org.springframework.scheduling.quartz.DelegatingJob",
  "durable" : false,
  "requestRecovery" : false,
  "data" : {
    "password" : "secret",
    "user" : "admin"
  },
  "triggers" : [ {
    "group" : "samples",
    "name" : "every-day",
    "previousFireTime" : "2020-12-04T03:00:00.000+00:00",
    "nextFireTime" : "2020-12-04T12:00:00.000+00:00",
    "priority" : 7
  }, {
    "group" : "samples",
    "name" : "3am-weekdays",
    "nextFireTime" : "2020-12-07T03:00:00.000+00:00",
    "priority" : 3
  } ]
}

如果数据映射中的某个 key 被识别为敏感信息,其值将被脱敏处理。

响应结构

响应包含作业的全部详细信息,包括其关联触发器(如有)的摘要。 触发器按下次触发时间和优先级排序。 下表描述了响应的结构:

Path Type Description

group

String

Name of the group.

name

String

Name of the job.

description

String

Description of the job, if any.

className

String

Fully qualified name of the job implementation.

durable

Boolean

Whether the job should remain stored after it is orphaned.

requestRecovery

Boolean

Whether the job should be re-executed if a 'recovery' or 'fail-over' situation is encountered.

data.*

String

Job data map as key/value pairs, if any.

triggers

Array

An array of triggers associated to the job, if any.

triggers.[].group

String

Name of the trigger group.

triggers.[].name

String

Name of the trigger.

triggers.[].previousFireTime

String

Last time the trigger fired, if any.

triggers.[].nextFireTime

String

Next time at which the Trigger is scheduled to fire, if any.

triggers.[].priority

Number

Priority to use if two triggers have the same scheduled fire time.

按需触发 Quartz 作业

要按需触发某个 Quartz 作业,请对 /actuator/quartz/jobs/{groupName}/{jobName} 发起 POST 请求,如下所示:

$ curl 'http://localhost:8080/actuator/quartz/jobs/samples/jobOne' -i -X POST \
    -H 'Content-Type: application/json' \
    -d '{"state":"running"}'

上述示例演示了如何触发属于 samples 分组且名为 jobOne 的作业。

响应内容如下所示:

HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 166

{
  "group" : "samples",
  "name" : "jobOne",
  "className" : "org.springframework.scheduling.quartz.DelegatingJob",
  "triggerTime" : "2025-05-26T03:08:26.074329Z"
}

请求结构

请求需指定与特定作业关联的期望 state。 发送带有 "state": "running" 的 HTTP 请求体表示该作业应立即运行。 下表描述了请求的结构:

Path Type Description

state

String

The desired state of the job.

响应结构

响应包含被触发作业的详细信息。 下表描述了响应的结构:

Path Type Description

group

String

Name of the group.

name

String

Name of the job.

className

String

Fully qualified name of the job implementation.

triggerTime

String

Time the job is triggered.

获取触发器详情

要获取某个触发器的详细信息,请对 /actuator/quartz/triggers/{groupName}/{triggerName} 发起 GET 请求,如下所示:

$ curl 'http://localhost:8080/actuator/quartz/triggers/samples/example' -i -X GET

上述示例获取了由 samples 分组和 example 名称标识的触发器详情。

通用响应结构

响应包含通用结构和特定于触发器类型的附加对象。 支持以下五种类型:

  • cron —— CronTrigger

  • simple —— SimpleTrigger

  • dailyTimeInterval —— DailyTimeIntervalTrigger

  • calendarInterval —— CalendarIntervalTrigger

  • custom —— 其他任何触发器实现

下表描述了响应通用部分的结构:

Path Type Description

group

String

Name of the group.

name

String

Name of the trigger.

description

String

Description of the trigger, if any.

state

String

State of the trigger (NONE, NORMAL, PAUSED, COMPLETE, ERROR, BLOCKED).

type

String

Type of the trigger (calendarInterval, cron, custom, dailyTimeInterval, simple). Determines the key of the object containing type-specific details.

calendarName

String

Name of the Calendar associated with this Trigger, if any.

startTime

String

Time at which the Trigger should take effect, if any.

endTime

String

Time at which the Trigger should quit repeating, regardless of any remaining repeats, if any.

previousFireTime

String

Last time the trigger fired, if any.

nextFireTime

String

Next time at which the Trigger is scheduled to fire, if any.

priority

Number

Priority to use if two triggers have the same scheduled fire time.

finalFireTime

String

Last time at which the Trigger will fire, if any.

data

Object

Job data map keyed by name, if any.

calendarInterval

Object

Calendar time interval trigger details, if any. Present when type is calendarInterval.

custom

Object

Custom trigger details, if any. Present when type is custom.

cron

Object

Cron trigger details, if any. Present when type is cron.

dailyTimeInterval

Object

Daily time interval trigger details, if any. Present when type is dailyTimeInterval.

simple

Object

Simple trigger details, if any. Present when type is simple.

Cron Trigger 响应结构

cron 触发器定义了用于确定其触发时机的 cron 表达式。 此类触发器实现的响应内容如下:

HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 490

{
  "group" : "samples",
  "name" : "example",
  "description" : "Example trigger",
  "state" : "NORMAL",
  "type" : "cron",
  "calendarName" : "bankHolidays",
  "startTime" : "2020-11-30T17:00:00.000+00:00",
  "endTime" : "2020-12-30T03:00:00.000+00:00",
  "previousFireTime" : "2020-12-04T03:00:00.000+00:00",
  "nextFireTime" : "2020-12-07T03:00:00.000+00:00",
  "priority" : 3,
  "data" : { },
  "cron" : {
    "expression" : "0 0 3 ? * 1,2,3,4,5",
    "timeZone" : "Europe/Paris"
  }
}

大部分响应内容对所有触发器类型通用。 通用部分结构已在 前文 描述。 下表描述了 cron 触发器特有部分的结构:

Path Type Description

cron

Object

Cron trigger specific details.

cron.expression

String

Cron expression to use.

cron.timeZone

String

Time zone for which the expression will be resolved, if any.

Simple Trigger 响应结构

simple 触发器用于在指定时间点触发作业,并可选地按指定间隔重复。 此类触发器实现的响应内容如下:

HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 549

{
  "group" : "samples",
  "name" : "example",
  "description" : "Example trigger",
  "state" : "NORMAL",
  "type" : "simple",
  "calendarName" : "bankHolidays",
  "startTime" : "2020-11-30T17:00:00.000+00:00",
  "endTime" : "2020-12-30T03:00:00.000+00:00",
  "previousFireTime" : "2020-12-04T03:00:00.000+00:00",
  "nextFireTime" : "2020-12-07T03:00:00.000+00:00",
  "priority" : 7,
  "finalFireTime" : "2020-12-29T17:00:00.000+00:00",
  "data" : { },
  "simple" : {
    "interval" : 86400000,
    "repeatCount" : -1,
    "timesTriggered" : 0
  }
}

大部分响应内容对所有触发器类型通用。 通用部分结构已在 前文 描述。 下表描述了 simple 触发器特有部分的结构:

Path Type Description

simple

Object

Simple trigger specific details.

simple.interval

Number

Interval, in milliseconds, between two executions.

simple.repeatCount

Number

Number of times the trigger should repeat, or -1 to repeat indefinitely.

simple.timesTriggered

Number

Number of times the trigger has already fired.

Daily Time Interval Trigger 响应结构

daily time interval 触发器用于基于每日重复时间间隔触发作业。 此类触发器实现的响应内容如下:

HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 667

{
  "group" : "samples",
  "name" : "example",
  "description" : "Example trigger",
  "state" : "PAUSED",
  "type" : "dailyTimeInterval",
  "calendarName" : "bankHolidays",
  "startTime" : "2020-11-30T17:00:00.000+00:00",
  "endTime" : "2020-12-30T03:00:00.000+00:00",
  "previousFireTime" : "2020-12-04T03:00:00.000+00:00",
  "nextFireTime" : "2020-12-07T03:00:00.000+00:00",
  "priority" : 5,
  "finalFireTime" : "2020-12-30T10:00:00.000+00:00",
  "data" : { },
  "dailyTimeInterval" : {
    "interval" : 3600000,
    "daysOfWeek" : [ 3, 5 ],
    "startTimeOfDay" : "09:00:00",
    "endTimeOfDay" : "18:00:00",
    "repeatCount" : -1,
    "timesTriggered" : 0
  }
}

大部分响应内容对所有触发器类型通用。 通用部分结构已在 前文 描述。 下表描述了 daily time interval 触发器特有部分的结构:

Path Type Description

dailyTimeInterval

Object

Daily time interval trigger specific details.

dailyTimeInterval.interval

Number

Interval, in milliseconds, added to the fire time in order to calculate the time of the next trigger repeat.

dailyTimeInterval.daysOfWeek

Array

An array of days of the week upon which to fire.

dailyTimeInterval.startTimeOfDay

String

Time of day to start firing at the given interval, if any.

dailyTimeInterval.endTimeOfDay

String

Time of day to complete firing at the given interval, if any.

dailyTimeInterval.repeatCount

Number

Number of times the trigger should repeat, or -1 to repeat indefinitely.

dailyTimeInterval.timesTriggered

Number

Number of times the trigger has already fired.

Calendar Interval Trigger 响应结构

calendar interval 触发器用于基于重复日历时间间隔触发作业。 此类触发器实现的响应内容如下:

HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 675

{
  "group" : "samples",
  "name" : "example",
  "description" : "Example trigger",
  "state" : "NORMAL",
  "type" : "calendarInterval",
  "calendarName" : "bankHolidays",
  "startTime" : "2020-11-30T17:00:00.000+00:00",
  "endTime" : "2020-12-30T03:00:00.000+00:00",
  "previousFireTime" : "2020-12-04T03:00:00.000+00:00",
  "nextFireTime" : "2020-12-07T03:00:00.000+00:00",
  "priority" : 5,
  "finalFireTime" : "2020-12-28T17:00:00.000+00:00",
  "data" : { },
  "calendarInterval" : {
    "interval" : 604800000,
    "timeZone" : "Asia/Shanghai",
    "timesTriggered" : 0,
    "preserveHourOfDayAcrossDaylightSavings" : false,
    "skipDayIfHourDoesNotExist" : false
  }
}

大部分响应内容对所有触发器类型通用。 通用部分结构已在 前文 描述。 下表描述了 calendar interval 触发器特有部分的结构:

Path Type Description

calendarInterval

Object

Calendar interval trigger specific details.

calendarInterval.interval

Number

Interval, in milliseconds, added to the fire time in order to calculate the time of the next trigger repeat.

calendarInterval.timeZone

String

Time zone within which time calculations will be performed, if any.

calendarInterval.timesTriggered

Number

Number of times the trigger has already fired.

calendarInterval.preserveHourOfDayAcrossDaylightSavings

Boolean

Whether to fire the trigger at the same time of day, regardless of daylight saving time transitions.

calendarInterval.skipDayIfHourDoesNotExist

Boolean

Whether to skip if the hour of the day does not exist on a given day.

Custom Trigger 响应结构

custom 触发器为其他任何实现。 此类触发器实现的响应内容如下:

HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 457

{
  "group" : "samples",
  "name" : "example",
  "description" : "Example trigger.",
  "state" : "NORMAL",
  "type" : "custom",
  "calendarName" : "bankHolidays",
  "startTime" : "2020-11-30T17:00:00.000+00:00",
  "endTime" : "2020-12-30T03:00:00.000+00:00",
  "previousFireTime" : "2020-12-04T03:00:00.000+00:00",
  "nextFireTime" : "2020-12-07T03:00:00.000+00:00",
  "priority" : 10,
  "custom" : {
    "trigger" : "com.example.CustomTrigger@fdsfsd"
  }
}

大部分响应内容对所有触发器类型通用。 通用部分结构已在 前文 描述。 下表描述了 custom 触发器特有部分的结构:

Path Type Description

custom

Object

Custom trigger specific details.

custom.trigger

String

A toString representation of the custom trigger instance.