1. Quartz主要配置

属性名称 是否必选 类型 默认值 说明
org.quartz.scheduler.instanceName String QuartzScheduler Schedule调度器的实体名字
org.quartz.scheduler.instanceId String NON_CLUSTERED Schedule调度器的实体的Id,必须唯一。
1. 当你想生成intanceId的时候可以设置为AUTO
2. 当你想从系统属性org.quartz.scheduler.instanceId取值时可以设置为SYS_PROP
org.quartz.scheduler.instanceIdGenerator.class String(类名) org.quartz.simpl.SimpleInstanceIdGenerator 生成Schudule实体Id的类,只有在属性org.quartz.scheduler.instanceId设置为AUTO时使用,默认的实现org.quartz.scheduler.SimpleInstanceGenerator是基于主机名称和时间戳生成。其他的实现查看具体的文档
org.quartz.scheduler.threadName String instanceName + ‘_QuartzSchedulerThread’ Scheduler线程的名称
org.quartz.scheduler.makeSchedulerThreadDaemon boolean false 指定Scheduler是否以守护线程(服务)运行
org.quartz.scheduler.threadsInheritContextClassLoaderOfInitializer boolean false 目前不太理解
org.quartz.scheduler.idleWaitTime long 30000 当调度程序空闲时,在重新查询可用触发器之前,调度程序将等待毫秒的时间数。不建议少于5000ms,而少于1000是不合法的参数
org.quartz.scheduler.doFailureRetryInterval long 15000 使用JobStore(比如连接数据库)时Schueduler检测到失去数据库连接后重新尝试连接的毫秒数
org.quartz.scheduler.classLoadHelper.class String(类名) org.quartz.simpl.CascadingClassLoaderHelper 目前不太了解
org.quartz.scheduler.jobFactory.class String(类名) org.quartz.simpl.PropertySettingJobFctory 给Scheduler Context、Job、Trigger的JobDataMaps设置属性值的方式
org.quartz.contenxt.key.SOME_KEY String None 键值对,保存在Scheduler Context中,比如有这样的配置org.quartz.shceduler.key.MyKey=MyValue,则在Scheduler Context中赋值方式为scheduler.getContext().put(“MyKey”, “MyValue”
org.quartz.scheduler.userTransactionURL String(url) java:comp/UserTransaction 事务管理JNDI URL地址。只有当Quartz使用JobStoreCMT和org.quartz.scheduler.wrapJobExecutionInUserTransaction 设置为true时使用
org.quartz.scheduler.wrapJobExecutionInUserTransaction boolean false 只有当你在执行一个Job时想使用UserTransaction时设置为true,参考@ExecuteInJTATransaction 注解
org.quartz.scheduler.skipUpdateCheck boolean false 是否跳过版本检测。可以设置系统参数org.terracotta.quartz.skipUpdateCheck=true或者在JAVA命令行使用-D选项。在正式库运行时应设置为true。
org.quartz.scheduler.batchTriggerAcquisitionMaxCount int 1 在同一时间运行Scheduler获取trigger的数量。如果设置的数量>1,并且使用JDBC JobStore,则属性org.quartz.jobStore.acquireTriggersWithinLock应设置为true,可以避破坏数据。
org.quartz.scheduler.batchTriggerAcquisitionFireAheadTimeWindow long 0 运行Scheduler在获取和触发tigger的提前的时间。

2. 线程池配置

2.1 主要配置

属性名称 是否必选 类型 默认值 说明
org.quartz.threadPool.class String(类名) null Scheduler使用的线程池名称,实现了ThreadPool接口,参考org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount int -1 线程池里面的线程的数据,取值在1-100
org.quartz.threadPool.threadPriority int Thread.NORM_PRIORITY (5) 线程的优先级,取值在Thread.MIN_PRIORITY(1)到Threa.MAX_PRIORITY(10)

2.2 线程池的简单配置

属性名称 是否必选 类型 默认值 说明
org.quartz.threadPool.makeThreadsDaemons boolean fale 指定在线程池里面创建的线程是否是守护线程
org.quartz.threadPool.threadsInheritGroupOfInitializingThread boolean true  
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread boolean false  
org.quartz.threadPool.threadNamePrefix String [Scheduler Name]_Workder 指定线程池里面线程的名字的前缀

3. Listener配置

在实例化StdSchedulerFactory的时候可以注册一个全局的监听器到Scheduler中,全局监听器会监听每一个Job和Trigger的触发事件。 
全局监听器必选有一个无参的构造函数,并且属性值只能是基本类型(包括String)。

配置例子:

//trigger listener配置
org.quartz.triggerListener.NAME = package.className
org.quartz.triggerListener.NAME.propName = propValue
//job listener配置
org.quartz.jobListener.NAME = package.className
org.quartz.jobListener.NAME.propName = propValue

  

4. JobStore配置

JobStore是Scheduler在运行时用来存储相关的信息的,比如Job, Trigger。

4.1 RAMJobStore

RAMJobStore实现类是在内存中存储信息的,程序一旦结束便丢失了相关的信息。

属性名称 是否必选 类型 默认值 说明
org.quartz.jobStore.class String(类名) org.quartz.simpl.RAMJobStore 指定使用的JobStore
org.quartz.jobStore.misfireThreshold int 60000 触发器失败后下次触发的时间间隔

4.2 JDBCJobStore和JobStoreTX

JDBCJobStore和JobStoreTX都使用关系数据库来存储Schedule相关的信息。

JobStoreTX在每次执行任务后都使用commint或者rollback来提交更改。

如果在一个标准的独立应用或者在一个没有使用JTA事务管理的应用中使用Quartz,JDBCJobStore是一个不错的选择。

JobStoreTX的配置如下:

属性名称 是否必选 类型 默认值 说明
org.quartz.jobStore.class String(类名) org.quartz.simpl.jdbcjobstore.JobStoreTX 使用JobStoreTX
org.quartz.jobStore.driverDelegateClass String(类名) null 使用的数据库驱动,具体的驱动列表详情如下
org.quartz.jobStore.dataSource String null 使用的数据源名称,具体参照数据源配置
org.quartz.jobStore.tablePrefix String QRTZ_ 表的前缀
org.quartz.jobStore.userProperties boolean false 标示在JobDataMaps的数据全部是String
org.quartz.jobStore.misfireThreshold int 60000 触发器触发失败后再次触犯的时间间隔
org.quartz.jobStore.isClustered boolean false 如果有多个调度器实体的话则必须设置为true
org.quartz.jobStore.clusterCheckinInterval long 15000 检查集群下的其他调度器实体的事件间隔
org.quartz.jobStore.maxMisfiresToHandleAtATime int 20  
org.quartz.jobStore.dontSetAutoCommintFalse boolean false  
org.quartz.jobStore.selectWithLockSQL String select * from {0}locks where sched_name = {1} and lock_name = ? for update  
org.quartz.jobStore.txlsolationLevelSerializable boolean false  
org.quartz.jobStore.acquireTriggersWithinLocal boolean false  
org.quartz.jobStore.lockHandler.class String null  
org.quartz.jobStore.driverDelegateInitString String null  

4.2.1 org.quartz.jobStore.driverDelegateClass数据库驱动列表

  • org.quartz.impl.jdbcstore.StdJDBCDelegate 适用于完全兼容JDBC的驱动
  • org.quartz.impl.jdbcstore.MSSQLDelegate 适用于Miscrosoft SQL Server和Sybase数据库
  • org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
  • org.quartz.impl.jdbcjobstore.WebLogicDelegate
  • org.quartz.impl.jdbcjobstore.oracle.OracleDelegate
  • org.quartz.impl.jdbcjobstore.oracle.WebLogicOracleDelegate
  • org.quartz.impl.jdbcjobstore.oracle.weblogic.WebLogicOracleDelegate
  • org.quartz.impl.jdbcjobstore.CloudscapeDelegate
  • org.quartz.impl.jdbcjobstore.DB2v6Delegate
  • org.quartz.impl.jdbcjobstore.DB2v7Delegate
  • org.quartz.impl.jdbcjobstore.DB2v8Delegate
  • org.quartz.impl.jdbcjobstore.HSQLDBDelegate
  • org.quartz.impl.jdbcjobstore.PointbaseDelegate
  • org.quartz.impl.jdbcjobstore.SybaseDelegate

5. 集群,使用JDBCJobStore和JobStoreTX

在JobStore使用JDBCJobStore、JobStoreTX、JobStoreCMT的情况下可以使用Quartz的集群特性,示意图如下:

简单的配置如下:

//主要配置
org.quartz.scheduler.instanceName = MyClusteredScheduler
org.quartz.scheduler.instanceId = AUTO //配置数据池连接
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 25
org.quartz.threadPool.treadPriority = 5 //JobStore配置
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcstore.oracle.OracleDelegate
org.quartz.jobStore.userProperties = true
org.quartz.jobStore.dataSource = myDS
org.quartz.jobStore.misfireThreshold = 60000 org.quartz.jobStore.isClustered = true
org.quartz.jobStore.clusterCheckinInterval = 20000 //DataSource数据源配置
org.quartz.dataSource.myDS.driver = oracle.jdbc.driver.OracleDriver
org.quartz.dataSource.myDS.URL = jdbc:oracle:thin:@localhost:1521:dev
org.quartz.dataSource.myDS.user = quartz
org.quartz.dataSource.myDS.password = quartz
org.quartz.dataSource.myDS.maxConnections = 5
org.quartz.dataSource.myDS.validationQuery=select 0 from dual

  

Quartz配置的更多相关文章

  1. 浅谈Spring中的Quartz配置

    浅谈Spring中的Quartz配置 2009-06-26 14:04 樊凯 博客园 字号:T | T Quartz是一个强大的企业级任务调度框架,Spring中继承并简化了Quartz,下面就看看在 ...

  2. spring多个定时任务quartz配置

    spring多个定时任务quartz配置 <?xml version=”1.0″ encoding=”UTF-8″?> <beans xmlns=”http://www.spring ...

  3. 使用spring+quartz配置多个定时任务

    Spring被用在了越来越多的项目中, quartz也被公认为是比较好用的定时器设置工具, 在这里通过一个demo说明如何使用spring和quartz配置多个定时任务. 环境: eclipse + ...

  4. Quartz 配置文件属性

    主要配置 Property Name Req'd Type Default Value org.quartz.scheduler.instanceName no string 'QuartzSched ...

  5. HangFire的定时任务和Quartz.NET总结(三)Quartz 配置

    在一个Net Core需求中,需要在每天的凌晨三点去抓取两个电商仓库的剩余的每个料号的数量来写会自己的表中, 用到了HangFire的定时任务 这篇文章讲的很详细记录下   文章2  这篇更简单 Qu ...

  6. Spring-----定时任务Quartz配置之手动设置

    一 配置xml如下: <!-- 定时任务配置 --> <bean id="scheduler" class="org.springframework.s ...

  7. spring quartz 配置实现定时任务 详解

    一. 编写定时任务JAVA类 比如: public class QuartzJob {     public QuartzJob(){         System.out.println(" ...

  8. Spring-----定时任务Quartz配置

    第一种,作业类继承自特定的基类:org.springframework.scheduling.quartz.QuartzJobBean. 第一步:定义作业类 import org.quartz.Job ...

  9. Quartz.NET总结(三)Quartz 配置

    前两篇文章,已经介绍了Quartz.NET的使用和Cron表达式表达式的写法,今天说一说Quartz的配置,Quartz相关的配置有三个quartz.config.quartz_jobs.xml.lo ...

  10. [代码]JAVA触发器,Spring的quartz配置

    Spring的quartz中的配置代码,spring-quartz.xml: <?xml version="1.0" encoding="UTF-8"?& ...

随机推荐

  1. springMVC入门(一)

    1.   SpringMVC入门 1.1SpringMVC是什么 Spring web mvc和Struts2都属于表现层的框架,它是Spring框架的一部分,我们可以从Spring的整体结构中看得出 ...

  2. 修改BlackLowKey皮肤样式,增加占屏比

    页面定制CSS代码 #home { margin: 0 auto; width: 100%; } #sideBar { min-height: 200px; padding: 0 5px 0 5px; ...

  3. 在Spring(4.3.22)中集成Hibernate(5.4.0)

    (1)pom中添加相关依赖 <dependency> <groupId>org.hibernate</groupId> <artifactId>hibe ...

  4. 恶意代码分析实战-x86反汇编速成班

    x86反汇编速成 x86体系结构 3种硬件构成: 中央处理器:负责执行代码 内存(RAM):负责存储所有的数据和代码 输入/输出系统(I/O):为硬盘.键盘.显示器等设备提供接口 内存 一个程序的内存 ...

  5. UML和模式应用4:初始阶段(4)--需求制品之用例模型模板示例

    1. 前言 UP开发包括四个阶段:初始阶段.细化阶段.构建阶段.移交阶段: UP每个阶段包括 业务建模.需求.设计等科目: 其中需求科目对应的需求制品包括:设想.业务规则.用例模型.补充性规格说明.词 ...

  6. win10安装virtualBox创建CentOS6.5虚拟机

    1.安装virtualBox 1.1.下载安装包,安装 搜索一下,或者去 VirtualBox官网下载一个. 下载第一个,兼容64,32位. 2.创建64位虚拟机 2.1.解决无法创建64位的问题 2 ...

  7. [转]解决win7 64位操作系统下安装PL/SQL后连接报错问题: make sure you have the 32 bits oracle client installed

    1. 在Oracle官网(http://www.oracle.com/technetwork/topics/winsoft-085727.html)下载文件: instantclient-basic- ...

  8. 源码编译安装mysql5.5.33

    源码编译安装mysql5.5.33 一.安装cmake编译工具 跨平台编译器 # yum install -y gcc* # yum install -y cmake 解决依赖关系 # yum ins ...

  9. 关于ftp上传changeWorkingDirectory()方法的路径切换问题

    在上传时 FTPClient提供了upload方法,对于upload(file,path)的第二个参数path ,上传到哪里的这个路径, ftp是利用changeWorkingDirectory()方 ...

  10. Python-html css 盒模型

    <!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>ht ...