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" ]
}
}
获取已注册作业名称
要获取已注册作业名称的列表,请对 /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" ]
}
}
}
获取已注册触发器名称
要获取已注册触发器名称的列表,请对 /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" ]
}
}
}
获取作业分组概览
要获取某一分组下作业的概览,请对 /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"
}
}
}
获取触发器分组概览
要获取某一分组下触发器的概览,请对 /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 |
---|---|---|
|
|
Name of the group. |
|
|
Whether the group is paused. |
|
|
Cron triggers keyed by name, if any. |
|
|
Simple triggers keyed by name, if any. |
|
|
Daily time interval triggers keyed by name, if any. |
|
|
Calendar interval triggers keyed by name, if any. |
|
|
Any other triggers keyed by name, if any. |
|
|
Last time the trigger fired, if any. |
|
|
Next time at which the Trigger is scheduled to fire, if any. |
|
|
Priority to use if two triggers have the same scheduled fire time. |
|
|
Cron expression to use. |
|
|
Time zone for which the expression will be resolved, if any. |
|
|
Last time the trigger fired, if any. |
|
|
Next time at which the Trigger is scheduled to fire, if any. |
|
|
Priority to use if two triggers have the same scheduled fire time. |
|
|
Interval, in milliseconds, between two executions. |
|
|
Last time the trigger fired, if any. |
|
|
Next time at which the Trigger is scheduled to fire, if any. |
|
|
Priority to use if two triggers have the same scheduled fire time. |
|
|
Interval, in milliseconds, added to the fire time in order to calculate the time of the next trigger repeat. |
|
|
An array of days of the week upon which to fire. |
|
|
Time of day to start firing at the given interval, if any. |
|
|
Time of day to complete firing at the given interval, if any. |
|
|
Last time the trigger fired, if any. |
|
|
Next time at which the Trigger is scheduled to fire, if any. |
|
|
Priority to use if two triggers have the same scheduled fire time. |
|
|
Interval, in milliseconds, added to the fire time in order to calculate the time of the next trigger repeat. |
|
|
Time zone within which time calculations will be performed, if any. |
|
|
Last time the trigger fired, if any. |
|
|
Next time at which the Trigger is scheduled to fire, if any. |
|
|
Priority to use if two triggers have the same scheduled fire time. |
|
|
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 |
---|---|---|
|
|
Name of the group. |
|
|
Name of the job. |
|
|
Description of the job, if any. |
|
|
Fully qualified name of the job implementation. |
|
|
Whether the job should remain stored after it is orphaned. |
|
|
Whether the job should be re-executed if a 'recovery' or 'fail-over' situation is encountered. |
|
|
Job data map as key/value pairs, if any. |
|
|
An array of triggers associated to the job, if any. |
|
|
Name of the trigger group. |
|
|
Name of the trigger. |
|
|
Last time the trigger fired, if any. |
|
|
Next time at which the Trigger is scheduled to fire, if any. |
|
|
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"
}
获取触发器详情
要获取某个触发器的详细信息,请对 /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 |
---|---|---|
|
|
Name of the group. |
|
|
Name of the trigger. |
|
|
Description of the trigger, if any. |
|
|
State of the trigger ( |
|
|
Type of the trigger ( |
|
|
Name of the Calendar associated with this Trigger, if any. |
|
|
Time at which the Trigger should take effect, if any. |
|
|
Time at which the Trigger should quit repeating, regardless of any remaining repeats, if any. |
|
|
Last time the trigger fired, if any. |
|
|
Next time at which the Trigger is scheduled to fire, if any. |
|
|
Priority to use if two triggers have the same scheduled fire time. |
|
|
Last time at which the Trigger will fire, if any. |
|
|
Job data map keyed by name, if any. |
|
|
Calendar time interval trigger details, if any. Present when |
|
|
Custom trigger details, if any. Present when |
|
|
Cron trigger details, if any. Present when |
|
|
Daily time interval trigger details, if any. Present when |
|
|
Simple trigger details, if any. Present when |
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 trigger specific details. |
|
|
Cron expression to use. |
|
|
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 trigger specific details. |
|
|
Interval, in milliseconds, between two executions. |
|
|
Number of times the trigger should repeat, or -1 to repeat indefinitely. |
|
|
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 |
---|---|---|
|
|
Daily time interval trigger specific details. |
|
|
Interval, in milliseconds, added to the fire time in order to calculate the time of the next trigger repeat. |
|
|
An array of days of the week upon which to fire. |
|
|
Time of day to start firing at the given interval, if any. |
|
|
Time of day to complete firing at the given interval, if any. |
|
|
Number of times the trigger should repeat, or -1 to repeat indefinitely. |
|
|
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 |
---|---|---|
|
|
Calendar interval trigger specific details. |
|
|
Interval, in milliseconds, added to the fire time in order to calculate the time of the next trigger repeat. |
|
|
Time zone within which time calculations will be performed, if any. |
|
|
Number of times the trigger has already fired. |
|
|
Whether to fire the trigger at the same time of day, regardless of daylight saving time transitions. |
|
|
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 trigger specific details. |
|
|
A toString representation of the custom trigger instance. |