Skip to content

Commit 18d4898

Browse files
authored
Update README.md
1 parent ff61dd1 commit 18d4898

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

README.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,84 @@
11
# example-spring-quartz
2+
3+
4+
> 基于 Spring Boot 3 的 quartz 集群定时任务,保证集群环境中同时只运行一个任务
5+
6+
7+
- spring 配置属性类`org.springframework.boot.autoconfigure.quartz.QuartzProperties`
8+
- spring boot 3 自动装配类`org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration`
9+
- 自定义生成实例名称,需要实现`org.quartz.spi.InstanceIdGenerator`接口
10+
- 自定义Job监听事件,需要实现`org.quartz.JobListener`接口
11+
12+
# table 信息
13+
14+
15+
| 表名 | 说明 |
16+
| ------------------------- | ------------------------------------------------------------ |
17+
| qrtz_blob_triggers | Trigger作为Blob类型存储(用于Quartz用户用JDBC创建他们自己定制的Trigger类型,JobStore 并不知道如何存储实例的时候) |
18+
| qrtz_calendars | 以Blob类型存储Quartz的Calendar日历信息, quartz可配置一个日历来指定一个时间范围 |
19+
| qrtz_cron_triggers | 存储Cron Trigger,包括Cron表达式和时区信息。 |
20+
| qrtz_fired_triggers | 存储与已触发的Trigger相关的状态信息,以及相联Job的执行信息 |
21+
| qrtz_job_details | 存储每一个已配置的Job的详细信息 |
22+
| qrtz_locks | 存储程序的非观锁的信息(假如使用了悲观锁) |
23+
| qrtz_paused_trigger_graps | 存储已暂停的Trigger组的信息 |
24+
| qrtz_scheduler_state | 存储少量的有关 Scheduler的状态信息,和别的 Scheduler 实例(假如是用于一个集群中) |
25+
| qrtz_simple_triggers | 存储简单的 Trigger,包括重复次数,间隔,以及已触的次数 |
26+
| qrtz_triggers | 存储已配置的 Trigger的信息 |
27+
| qrzt_simprop_triggers | 存储已配置的 Trigger的信息 |
28+
29+
# 表字段详细介绍
30+
31+
[表字段详细介绍](http://www.ibloger.net/article/2650.html)
32+
33+
34+
# Spring Quartz 配置
35+
36+
37+
```yaml
38+
spring:
39+
profiles:
40+
active: dev
41+
## QuartzProperties
42+
quartz:
43+
jdbc:
44+
initialize-schema: embedded
45+
job-store-type: jdbc
46+
properties:
47+
# Configure Main Scheduler Properties
48+
# 调度器实例名称
49+
org.quartz:scheduler.instanceName: spring-boot-quartz-cluster-example
50+
# 调度器实例编号自动生成
51+
org.quartz.scheduler.instanceId: AUTO
52+
53+
# Configure JobStore
54+
# 持久化方式配置
55+
org.quartz.jobStore.class: org.quartz.impl.jdbcjobstore.JobStoreTX
56+
# 持久化方式配置数据驱动,MySQL数据库
57+
org.quartz.jobStore.driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate
58+
# 配置是否使用
59+
org.quartz.jobStore.useProperties: true
60+
org.quartz.jobStore.misfireThreshold: 60000
61+
# quartz相关数据表前缀名
62+
#org.quartz.jobStore.tablePrefix: QRTZ_
63+
# 打开集群配置
64+
org.quartz.jobStore.isClustered: true
65+
# 设置集群检查间隔20s
66+
org.quartz.jobStore.clusterCheckinInterval: 20000
67+
68+
# Configure ThreadPool
69+
# 线程池实现类
70+
org.quartz.threadPool.class: org.quartz.simpl.SimpleThreadPool
71+
# 执行最大并发线程数量
72+
org.quartz.threadPool.threadCount: 10
73+
# 线程优先级
74+
org.quartz.threadPool.threadPriority: 5
75+
#配置为守护线程,设置后任务将不会执行
76+
#org.quartz.threadPool.makeThreadsDaemons=true
77+
#配置是否启动自动加载数据库内的定时任务,默认true
78+
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread: true
79+
```
80+
81+
82+
83+
84+

0 commit comments

Comments
 (0)