quartz 持久化 数据库表
此处只包括配置数据库操作

quartz 持久化数据库表格字段解释建表,SQL语句在dbTables文件夹中可以找到,介绍下我们开发主要使用到的表: (版本不一样,可能数据库表也不一样,这里使用2.2.1)
1、QRTZ_JOB_DETAILS:存储的是job的详细信息,包括:[DESCRIPTION]描述,[IS_DURABLE]是否持久化,[JOB_DATA]持久化对象等基本信息。
2、QRTZ_TRIGGERS:触发器信息,包含:job的名,组外键,[DESCRIPTION]触发器的描述等基本信息,还有[START_TIME]开始执行时间,[END_TIME]结束执行时间,[PREV_FIRE_TIME]上次执行时间,[NEXT_FIRE_TIME]下次执行时间,[TRIGGER_TYPE]触发器类型:simple和cron,[TRIGGER_STATE]执行状态:WAITING,PAUSED,ACQUIRED分别为:等待,暂停,运行中。
3、QRTZ_CRON_TRIGGERS:保存cron表达式。
4、QRTZ_SCHEDULER_STATE:存储集群中note实例信息,quartz会定时读取该表的信息判断集群中每个实例的当前状态,INSTANCE_NAME:之前配置文件中org.quartz.scheduler.instanceId配置的名字,就会写入该字段,如果设置为AUTO,quartz会根据物理机名和当前时间产生一个名字。 [LAST_CHECKIN_TIME]上次检查时间,[CHECKIN_INTERVAL]检查间隔时间。
5、QRTZ_PAUSED_TRIGGER_GRPS:暂停的任务组信息。
6、QRTZ_LOCKS,悲观锁发生的记录信息。
7、QRTZ_FIRED_TRIGGERS,正在运行的触发器信息。
8、QRTZ_SIMPLE_TRIGGERS,简单的出发器详细信息。
9、QRTZ_BLOB_TRIGGERS,触发器存为二进制大对象类型(用于Quartz用户自己触发数据库定制自己的触发器,然而JobStore不明白怎么存放实例的时候)。
quartz.properties
# Default Properties file for use by StdSchedulerFactory
# to create a Quartz Scheduler Instance, if a different
# properties file is not explicitly specified.
# org.quartz.scheduler.instanceName= DefaultQuartzScheduler
org.quartz.scheduler.rmi.export= false
org.quartz.scheduler.rmi.proxy= false
org.quartz.scheduler.wrapJobExecutionInUserTransaction= false org.quartz.threadPool.class= org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount= 10
org.quartz.threadPool.threadPriority= 5
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread= true org.quartz.jobStore.misfireThreshold= 60000 org.quartz.jobStore.class= org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
org.quartz.jobStore.tablePrefix = QRTZ_ #不需要整合其他框架数据库时--------需要整合时,以下备注相反即可
org.quartz.jobStore.dataSource = qzDS org.quartz.dataSource.qzDS.driver= net.sourceforge.jtds.jdbc.Driver
org.quartz.dataSource.qzDS.URL = jdbc:jtds:sqlserver://localhost:1433/quartz
org.quartz.dataSource.qzDS.user= sa
org.quartz.dataSource.qzDS.password= 1234
org.quartz.dataSource.qzDS.maxConnections = 30
#org.quartz.jobStore.selectWithLockSQL=select * from {0}LOCKS UPDLOCK WHERE LOCK_NAME=?
整合SpringMVC:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- 导入数据库配置 -->
<import resource="spring-datasources.xml"/>
<!-- 配置job可使用springmvc bean -->
<bean id="jobFactory" class="com.ice.quartz.factory.JobFactory"></bean>
<bean id="jobRecordListener" class="com.ice.quartz.listener.JobRecordListener" />
<bean id="triggerRecordListener" class="com.ice.quartz.listener.TriggerRecordListener" />
<bean id="DefaultQuartzScheduler" lazy-init="false" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="dataSource" ref="defaultDataSource"/>
<property name="configLocation" value="classpath:quartz.properties" />
<property name="jobFactory" ref="jobFactory"></property>
<property name="triggers">
<list>
<ref bean="hourTrigger"></ref>
<ref bean="dayTrigger"></ref>
<ref bean="weekTrigger"></ref>
<ref bean="monthTrigger"></ref>
<ref bean="quarterTrigger"></ref>
<ref bean="yearTrigger"></ref>
</list>
</property>
<!-- 使用注入方式使用springMVC bean -->
<property name="schedulerContextAsMap">
<map>
<entry key="jobTriggerRecordMapper" value-ref="jobTriggerRecordMapper"></entry>
</map>
</property>
<property name="globalJobListeners" ref="jobRecordListener"></property>
<property name="globalTriggerListeners" ref="triggerRecordListener"></property>
</bean>
</beans>
配置job可使用springmvc bean
package com.ice.quartz.factory; import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.scheduling.quartz.SpringBeanJobFactory; /**
* @author sky
* @version 1.0
* @since 4.0
*/
public class JobFactory extends SpringBeanJobFactory implements ApplicationContextAware {
private ApplicationContext applicationContext; @Override
protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
Object jobInstance = super.createJobInstance(bundle);
applicationContext.getAutowireCapableBeanFactory().autowireBean(jobInstance);
return jobInstance;
} @Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
}
quartz 持久化 数据库表的更多相关文章
- 【Quartz】Quartz的数据库表
select * from test.QRTZ_TRIGGERS 触发器表 select * from QRTZ_PAUSED_TRIGGER_GRPS 暂停的分组任务表 select * from ...
- 【quartz】 数据库方式管理任务
public static void Run(bool inClearJobs, bool inScheduleJobs) { var properties = new NameValueCollec ...
- 数据库表结构设计方法及原则(li)
数据库设计的三大范式:为了建立冗余较小.结构合理的数据库,设计数据库时必须遵循一定的规则.在关系型数据库中这种规则就称为范式.范式是符合某一种设计要求的总结.要想设计一个结构合理的关系型数据库,必须满 ...
- Zend Framework 2参考Zend\Authentication(数据库表认证)
+ 转载自:Zend Framework 2参考Zend\Authentication(数据库表认证) 介绍 Zend\Authentication\Adapter\DbTable提供对存储在数据库表 ...
- Activiti5.13数据库表结构设计
1.结构设计 1.1. 逻辑结构设计 Activiti使用到的表都是ACT_开头的. ACT_RE_*: ’RE’表示repository(存储),RepositoryService接口所操作的 ...
- Spring Boot整合Quartz实现定时任务表配置
最近有个小项目要做,spring mvc下的task设置一直不太灵活,因此在Spring Boot上想做到灵活的管理定时任务.需求就是,当项目启动的时候,如果有定时任务则加载进来,生成schedule ...
- activiti数据库表结构剖析
1.结构设计 1.1. 逻辑结构设计 Activiti使用到的表都是ACT_开头的. ACT_RE_*: ’RE’表示repository(存储),RepositoryService接口所操作的 ...
- MySQL中的information_schema数据库表说明
MySQL 中的 information_schema 数据库 版权声明:https://blog.csdn.net/kikajack/article/details/80065753 1. 概述 ...
- Spring Quartz 持久化解决方案
Quartz是实现了序列化接口的,包括接口,所以可以使用标准方式序列化到数据库. 而Spring2.5.6在集成Quartz时却未能考虑持久化问题. Spring对JobDetail进行了封装,却未实 ...
随机推荐
- [HDU5686]2016"百度之星" - 资格赛 Problem B
题目大意:给你n,规定一个串中相邻的两个1可以合并为一个2(别的不行),让你求长度为n的全1串最多能变成多少种不同的串. 解题思路:我们先来找一波规律,发现n=1,2,3,4,5时答案分别为1,2,3 ...
- [NOIP2015普及组]推销员
题目:洛谷P2672.codevs5126.Vijos P1977 题目大意:有个推销员要去推销,要你求他推销1~n户人家分别最多花多少“疲劳值”.具体见题目. 解题思路:如果用$O(n^2)$做的话 ...
- python scrapy爬取HBS 汉堡南美航运公司柜号信息
下面分享个scrapy的例子 利用scrapy爬取HBS 船公司柜号信息 1.前期准备 查询提单号下的柜号有哪些,主要是在下面的网站上,输入提单号,然后点击查询 https://www.hamburg ...
- HDU 4366 Successor
Successor Time Limit: 1000ms Memory Limit: 65536KB This problem will be judged on HDU. Original ID: ...
- LibSVM-windows
本系列文章由 @YhL_Leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/50112477 官方Web: https ...
- 数学之路-python计算实战(18)-机器视觉-滤波去噪(双边滤波与高斯滤波 )
高斯滤波就是对整幅图像进行加权平均的过程.每个像素点的值,都由其本身和邻域内的其它像素值经过加权平均后得到.高斯滤波的详细操作是:用一个模板(或称卷积.掩模)扫描图像中的每个像素.用模板确定的邻域内像 ...
- poj_3371
一道模拟题,写的有点麻烦 #include<iostream> #include<cstring> #include<cstdio> #include<alg ...
- 自定义标签 Unable to find setter method for attribute
变量的首字母不能大写 http://blog.csdn.net/looksun/article/details/7690601
- iOS数据持久化 -- Core Data
Core Data是一个功能强大的层,位于SQLite数据库之上,它避免了SQL的复杂性,能让我们以更自然的方式与数据库进行交互.Core Data将数据库行转换为OC对象(托管对象)来实现,这样无需 ...
- POJ 3668 枚举?
枚举两点,算一下斜率 sort一遍 判个重 输出解 25行 搞定- //By SiriusRen #include <cmath> #include <cstdio> #inc ...