- 浏览: 249487 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (192)
- 技术研究学习 (19)
- 工作总结 (4)
- spring3.x (11)
- mail (2)
- jar (2)
- FCKeditor (1)
- quartz (2)
- json (1)
- jdbc (5)
- struts2 (6)
- java基础 (18)
- jboss (3)
- IT名称解析 (1)
- 测试工具 (2)
- 工作趣谈 (1)
- 数据库 (8)
- js (8)
- jquery (1)
- mysql (20)
- Sql (3)
- Oracle (1)
- easyui (0)
- log4j (1)
- 源码研究 (1)
- Jasper Report (0)
- Jbpm4 (4)
- xml (1)
- ireport (0)
- javavm (1)
- sitemesh (5)
- compass (1)
- jvm (1)
- ext (1)
- lucene (0)
- cxf (1)
- Blazeds (0)
- Resteasy (1)
- jaxb (1)
- tomcat (1)
- Rmi (1)
- BoneCP (1)
- velocity (3)
- OSCache (1)
- EHCache (1)
- 高性能开发 (9)
- 设计模式 (0)
- 网络协议应用 (1)
- Ibatis (1)
- powerdesigner (1)
- 架构师之路 (2)
- memcached (4)
- MapReduce (1)
- 测试组 (1)
- 图像处理 (2)
- LoadRunner (2)
- 报表 (1)
- 负载均衡 (1)
- 分布式 (3)
- c# (1)
- java中一些特殊问题 (3)
- java 8 (1)
- Mogodb (1)
- 项目设计与实现 (2)
- Ubuntu (1)
- eclipse (1)
- gradle (1)
- 私有云 (1)
- redis (1)
- 移动前端 (1)
最新评论
由于集群只能工作在JDBC-Jobstore(JobStoreTX或者JobStoreCMT)方式下。需要先准备好quartz的数据库环境。
1.在 quartz 的官网上(http://quartz-scheduler.org/ )下载quartz框架的最新版本(目前是1.8.6),下载quartz-1.8.6.tar.gz文件。
2.解压压缩文件quartz-1.8.6.tar.gz,在quartz-1.8.6\docs\dbTables\ 找到文件tables_oracle.sql(以oracle为例),在数据库中执行一遍,就可以看到quartz 框架
集群管理所需的表。
3.配置quartz.properties的quartz属性文件。
#============================================================================
# Configure Main Scheduler Properties
#============================================================================
org.quartz.scheduler.instanceName = Scheduler
org.quartz.scheduler.instanceId = AUTO
#============================================================================
# Configure ThreadPool
#============================================================================
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 10
org.quartz.threadPool.threadPriority = 5
#==============================================================
#Configure JobStore 集群配置
#==============================================================
org.quartz.jobStore.misfireThreshold = 60000
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.oracle.OracleDelegate
org.quartz.jobStore.tablePrefix = QRTZ_
org.quartz.jobStore.dataSource = myDS
org.quartz.jobStore.isClustered = true
org.quartz.jobStore.clusterCheckinInterval = 20000
#==============================================================
#Non-Managed Configure Datasource 集群数据库配置
#==============================================================
org.quartz.dataSource.myDS.driver = oracle.jdbc.driver.OracleDriver
org.quartz.dataSource.myDS.URL = jdbc:oracle:thin:@127.0.0.1/orcl
org.quartz.dataSource.myDS.user = username
org.quartz.dataSource.myDS.password = password
org.quartz.dataSource.myDS.maxConnections = 10
修改其中数据库相关配置为你自己用的。
org.quartz.jobStore.isClustered = true启用集群的配置项。
4. 定义一个作业类(Job)。
import java.util.Date;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
public class SimpleJob implements Job {
private static Log _log = LogFactory.getLog(SimpleJob.class);
public SimpleJob() {
}
public void execute(JobExecutionContext context)
throws JobExecutionException {
// This job simply prints out its job name and the
// date and time that it is running
String jobName = context.getJobDetail().getFullName();
_log.info("SimpleJob says: " + jobName + " executing at " + new Date());
}
}
5.定义作业的执行类。
import java.util.Date;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.CronTrigger;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerFactory;
import org.quartz.SchedulerMetaData;
import org.quartz.impl.StdSchedulerFactory;
public class JdbcJobStoreExample {
public void runCluster()throws Exception{
Log log = LogFactory.getLog(JdbcJobStoreExample.class);
log.info("------- Initializing -------------------");
// First we must get a reference to a scheduler
String propName = "conf/quartz_cluster.properties";
SchedulerFactory sf = new StdSchedulerFactory(propName);
Scheduler sched = sf.getScheduler();
log.info("------- Initialization Complete --------");
log.info("------- Scheduling Jobs ----------------");
log.info("------- Starting Scheduler ----------------");
// All of the jobs have been added to the scheduler, but none of the
// jobs
// will run until the scheduler has been started
sched.start();
log.info("------- Started Scheduler -----------------");
log.info("------- Waiting five minutes... ------------");
try {
// wait five minutes to show jobs
Thread.sleep(300L * 1000L);
// executing...
} catch (Exception e) {
}
log.info("------- Shutting Down ---------------------");
sched.shutdown(true);
log.info("------- Shutdown Complete -----------------");
SchedulerMetaData metaData = sched.getMetaData();
log.info("Executed " + metaData.getNumberOfJobsExecuted() + " jobs.");
}
public void run() throws Exception {
Log log = LogFactory.getLog(JdbcJobStoreExample.class);
log.info("------- Initializing -------------------");
// First we must get a reference to a scheduler
String propName = "conf/quartz_cluster.properties";
SchedulerFactory sf = new StdSchedulerFactory(propName);
Scheduler sched = sf.getScheduler();
log.info("------- Initialization Complete --------");
log.info("------- Scheduling Jobs ----------------");
// jobs can be scheduled before sched.start() has been called
// job 1 will run every 20 seconds
JobDetail job = new JobDetail("job1", "group1", SimpleJob.class);
CronTrigger trigger = new CronTrigger("trigger1", "group1", "job1",
"group1", "0/20 * * * * ?");
sched.addJob(job, true);
Date ft = sched.scheduleJob(trigger);
log.info(job.getFullName() + " has been scheduled to run at: " + ft
+ " and repeat based on expression: "
+ trigger.getCronExpression());
// job 2 will run every other minute (at 15 seconds past the minute)
job = new JobDetail("job2", "group1", SimpleJob.class);
trigger = new CronTrigger("trigger2", "group1", "job2", "group1",
"15 0/2 * * * ?");
sched.addJob(job, true);
ft = sched.scheduleJob(trigger);
log.info(job.getFullName() + " has been scheduled to run at: " + ft
+ " and repeat based on expression: "
+ trigger.getCronExpression());
// job 3 will run every other minute but only between 8am and 5pm
job = new JobDetail("job3", "group1", SimpleJob.class);
trigger = new CronTrigger("trigger3", "group1", "job3", "group1",
"0 0/2 8-17 * * ?");
sched.addJob(job, true);
ft = sched.scheduleJob(trigger);
log.info(job.getFullName() + " has been scheduled to run at: " + ft
+ " and repeat based on expression: "
+ trigger.getCronExpression());
// job 4 will run every three minutes but only between 5pm and 11pm
job = new JobDetail("job4", "group1", SimpleJob.class);
trigger = new CronTrigger("trigger4", "group1", "job4", "group1",
"0 0/3 17-23 * * ?");
sched.addJob(job, true);
ft = sched.scheduleJob(trigger);
log.info(job.getFullName() + " has been scheduled to run at: " + ft
+ " and repeat based on expression: "
+ trigger.getCronExpression());
// job 5 will run at 10am on the 1st and 15th days of the month
job = new JobDetail("job5", "group1", SimpleJob.class);
trigger = new CronTrigger("trigger5", "group1", "job5", "group1",
"0 0 10am 1,15 * ?");
sched.addJob(job, true);
ft = sched.scheduleJob(trigger);
log.info(job.getFullName() + " has been scheduled to run at: " + ft
+ " and repeat based on expression: "
+ trigger.getCronExpression());
// job 6 will run every 30 seconds but only on Weekdays (Monday through
// Friday)
job = new JobDetail("job6", "group1", SimpleJob.class);
trigger = new CronTrigger("trigger6", "group1", "job6", "group1",
"0,30 * * ? * MON-FRI");
sched.addJob(job, true);
ft = sched.scheduleJob(trigger);
log.info(job.getFullName() + " has been scheduled to run at: " + ft
+ " and repeat based on expression: "
+ trigger.getCronExpression());
// job 7 will run every 30 seconds but only on Weekends (Saturday and
// Sunday)
job = new JobDetail("job7", "group1", SimpleJob.class);
trigger = new CronTrigger("trigger7", "group1", "job7", "group1",
"0,30 * * ? * SAT,SUN");
sched.addJob(job, true);
ft = sched.scheduleJob(trigger);
log.info(job.getFullName() + " has been scheduled to run at: " + ft
+ " and repeat based on expression: "
+ trigger.getCronExpression());
log.info("------- Starting Scheduler ----------------");
// All of the jobs have been added to the scheduler, but none of the
// jobs
// will run until the scheduler has been started
sched.start();
log.info("------- Started Scheduler -----------------");
log.info("------- Waiting five minutes... ------------");
try {
// wait five minutes to show jobs
Thread.sleep(300L * 1000L);
// executing...
} catch (Exception e) {
}
log.info("------- Shutting Down ---------------------");
sched.shutdown(true);
log.info("------- Shutdown Complete -----------------");
SchedulerMetaData metaData = sched.getMetaData();
log.info("Executed " + metaData.getNumberOfJobsExecuted() + " jobs.");
}
/**
* @param args
*/
public static void main(String[] args) {
JdbcJobStoreExample test = new JdbcJobStoreExample();
try {
// test.run();
test. runCluster ();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("ok....");
}
}
在main()方法调用 test.run();方法会把作业调度信息持久化到数据库中。
test. runCluster ()是集群启动的方法,在启动集群方法前,首先要先执行一遍JdbcJobStoreExample类的run()方法,
因为我在run()方法中添加作业的调度信息,运行后quartz会把调度信息持久
化到数据库,也可以直接在数据库中配置作业的调度信息(由于本人比较懒,就这样偷懒了一下)。
6.程序中用到的jar文件如下:
commons-dbcp-1.3.jar
commons-logging-1.1.jar
commons-pool-1.5.4.jar
jta-1.1.jar
junit-4.5.jar
log4j-1.2.14.jar
oracle-driver-14.jar
quartz-all-1.8.5.jar
slf4j-api-1.6.0.jar
slf4j-log4j12-1.6.0.jar
7.在不同的位置运行多个程序(即调用该runCluster ()方法),集群就启动了。
来源:
http://www.cnblogs.com/honeybee/articles/2371540.html
1.在 quartz 的官网上(http://quartz-scheduler.org/ )下载quartz框架的最新版本(目前是1.8.6),下载quartz-1.8.6.tar.gz文件。
2.解压压缩文件quartz-1.8.6.tar.gz,在quartz-1.8.6\docs\dbTables\ 找到文件tables_oracle.sql(以oracle为例),在数据库中执行一遍,就可以看到quartz 框架
集群管理所需的表。
3.配置quartz.properties的quartz属性文件。
#============================================================================
# Configure Main Scheduler Properties
#============================================================================
org.quartz.scheduler.instanceName = Scheduler
org.quartz.scheduler.instanceId = AUTO
#============================================================================
# Configure ThreadPool
#============================================================================
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 10
org.quartz.threadPool.threadPriority = 5
#==============================================================
#Configure JobStore 集群配置
#==============================================================
org.quartz.jobStore.misfireThreshold = 60000
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.oracle.OracleDelegate
org.quartz.jobStore.tablePrefix = QRTZ_
org.quartz.jobStore.dataSource = myDS
org.quartz.jobStore.isClustered = true
org.quartz.jobStore.clusterCheckinInterval = 20000
#==============================================================
#Non-Managed Configure Datasource 集群数据库配置
#==============================================================
org.quartz.dataSource.myDS.driver = oracle.jdbc.driver.OracleDriver
org.quartz.dataSource.myDS.URL = jdbc:oracle:thin:@127.0.0.1/orcl
org.quartz.dataSource.myDS.user = username
org.quartz.dataSource.myDS.password = password
org.quartz.dataSource.myDS.maxConnections = 10
修改其中数据库相关配置为你自己用的。
org.quartz.jobStore.isClustered = true启用集群的配置项。
4. 定义一个作业类(Job)。
import java.util.Date;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
public class SimpleJob implements Job {
private static Log _log = LogFactory.getLog(SimpleJob.class);
public SimpleJob() {
}
public void execute(JobExecutionContext context)
throws JobExecutionException {
// This job simply prints out its job name and the
// date and time that it is running
String jobName = context.getJobDetail().getFullName();
_log.info("SimpleJob says: " + jobName + " executing at " + new Date());
}
}
5.定义作业的执行类。
import java.util.Date;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.CronTrigger;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerFactory;
import org.quartz.SchedulerMetaData;
import org.quartz.impl.StdSchedulerFactory;
public class JdbcJobStoreExample {
public void runCluster()throws Exception{
Log log = LogFactory.getLog(JdbcJobStoreExample.class);
log.info("------- Initializing -------------------");
// First we must get a reference to a scheduler
String propName = "conf/quartz_cluster.properties";
SchedulerFactory sf = new StdSchedulerFactory(propName);
Scheduler sched = sf.getScheduler();
log.info("------- Initialization Complete --------");
log.info("------- Scheduling Jobs ----------------");
log.info("------- Starting Scheduler ----------------");
// All of the jobs have been added to the scheduler, but none of the
// jobs
// will run until the scheduler has been started
sched.start();
log.info("------- Started Scheduler -----------------");
log.info("------- Waiting five minutes... ------------");
try {
// wait five minutes to show jobs
Thread.sleep(300L * 1000L);
// executing...
} catch (Exception e) {
}
log.info("------- Shutting Down ---------------------");
sched.shutdown(true);
log.info("------- Shutdown Complete -----------------");
SchedulerMetaData metaData = sched.getMetaData();
log.info("Executed " + metaData.getNumberOfJobsExecuted() + " jobs.");
}
public void run() throws Exception {
Log log = LogFactory.getLog(JdbcJobStoreExample.class);
log.info("------- Initializing -------------------");
// First we must get a reference to a scheduler
String propName = "conf/quartz_cluster.properties";
SchedulerFactory sf = new StdSchedulerFactory(propName);
Scheduler sched = sf.getScheduler();
log.info("------- Initialization Complete --------");
log.info("------- Scheduling Jobs ----------------");
// jobs can be scheduled before sched.start() has been called
// job 1 will run every 20 seconds
JobDetail job = new JobDetail("job1", "group1", SimpleJob.class);
CronTrigger trigger = new CronTrigger("trigger1", "group1", "job1",
"group1", "0/20 * * * * ?");
sched.addJob(job, true);
Date ft = sched.scheduleJob(trigger);
log.info(job.getFullName() + " has been scheduled to run at: " + ft
+ " and repeat based on expression: "
+ trigger.getCronExpression());
// job 2 will run every other minute (at 15 seconds past the minute)
job = new JobDetail("job2", "group1", SimpleJob.class);
trigger = new CronTrigger("trigger2", "group1", "job2", "group1",
"15 0/2 * * * ?");
sched.addJob(job, true);
ft = sched.scheduleJob(trigger);
log.info(job.getFullName() + " has been scheduled to run at: " + ft
+ " and repeat based on expression: "
+ trigger.getCronExpression());
// job 3 will run every other minute but only between 8am and 5pm
job = new JobDetail("job3", "group1", SimpleJob.class);
trigger = new CronTrigger("trigger3", "group1", "job3", "group1",
"0 0/2 8-17 * * ?");
sched.addJob(job, true);
ft = sched.scheduleJob(trigger);
log.info(job.getFullName() + " has been scheduled to run at: " + ft
+ " and repeat based on expression: "
+ trigger.getCronExpression());
// job 4 will run every three minutes but only between 5pm and 11pm
job = new JobDetail("job4", "group1", SimpleJob.class);
trigger = new CronTrigger("trigger4", "group1", "job4", "group1",
"0 0/3 17-23 * * ?");
sched.addJob(job, true);
ft = sched.scheduleJob(trigger);
log.info(job.getFullName() + " has been scheduled to run at: " + ft
+ " and repeat based on expression: "
+ trigger.getCronExpression());
// job 5 will run at 10am on the 1st and 15th days of the month
job = new JobDetail("job5", "group1", SimpleJob.class);
trigger = new CronTrigger("trigger5", "group1", "job5", "group1",
"0 0 10am 1,15 * ?");
sched.addJob(job, true);
ft = sched.scheduleJob(trigger);
log.info(job.getFullName() + " has been scheduled to run at: " + ft
+ " and repeat based on expression: "
+ trigger.getCronExpression());
// job 6 will run every 30 seconds but only on Weekdays (Monday through
// Friday)
job = new JobDetail("job6", "group1", SimpleJob.class);
trigger = new CronTrigger("trigger6", "group1", "job6", "group1",
"0,30 * * ? * MON-FRI");
sched.addJob(job, true);
ft = sched.scheduleJob(trigger);
log.info(job.getFullName() + " has been scheduled to run at: " + ft
+ " and repeat based on expression: "
+ trigger.getCronExpression());
// job 7 will run every 30 seconds but only on Weekends (Saturday and
// Sunday)
job = new JobDetail("job7", "group1", SimpleJob.class);
trigger = new CronTrigger("trigger7", "group1", "job7", "group1",
"0,30 * * ? * SAT,SUN");
sched.addJob(job, true);
ft = sched.scheduleJob(trigger);
log.info(job.getFullName() + " has been scheduled to run at: " + ft
+ " and repeat based on expression: "
+ trigger.getCronExpression());
log.info("------- Starting Scheduler ----------------");
// All of the jobs have been added to the scheduler, but none of the
// jobs
// will run until the scheduler has been started
sched.start();
log.info("------- Started Scheduler -----------------");
log.info("------- Waiting five minutes... ------------");
try {
// wait five minutes to show jobs
Thread.sleep(300L * 1000L);
// executing...
} catch (Exception e) {
}
log.info("------- Shutting Down ---------------------");
sched.shutdown(true);
log.info("------- Shutdown Complete -----------------");
SchedulerMetaData metaData = sched.getMetaData();
log.info("Executed " + metaData.getNumberOfJobsExecuted() + " jobs.");
}
/**
* @param args
*/
public static void main(String[] args) {
JdbcJobStoreExample test = new JdbcJobStoreExample();
try {
// test.run();
test. runCluster ();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("ok....");
}
}
在main()方法调用 test.run();方法会把作业调度信息持久化到数据库中。
test. runCluster ()是集群启动的方法,在启动集群方法前,首先要先执行一遍JdbcJobStoreExample类的run()方法,
因为我在run()方法中添加作业的调度信息,运行后quartz会把调度信息持久
化到数据库,也可以直接在数据库中配置作业的调度信息(由于本人比较懒,就这样偷懒了一下)。
6.程序中用到的jar文件如下:
commons-dbcp-1.3.jar
commons-logging-1.1.jar
commons-pool-1.5.4.jar
jta-1.1.jar
junit-4.5.jar
log4j-1.2.14.jar
oracle-driver-14.jar
quartz-all-1.8.5.jar
slf4j-api-1.6.0.jar
slf4j-log4j12-1.6.0.jar
7.在不同的位置运行多个程序(即调用该runCluster ()方法),集群就启动了。
来源:
http://www.cnblogs.com/honeybee/articles/2371540.html
发表评论
-
java集合查询测试结果
2013-06-08 09:41 1146package test.com; import j ... -
对象池修订版
2013-03-08 14:09 0public class ObjectPool { ... -
深入研究java.lang.Process类
2013-03-07 12:07 857一、概述 Process ... -
深入研究java.lang.Runtime类
2013-03-07 11:54 967一、概述 Runtime ... -
JAVA图像缩放处理
2012-11-09 16:33 914import java.awt.image.Buffere ... -
oa
2012-10-19 18:03 0http://code.google.com/p/joffic ... -
Frameset导致Cookies和Session丢失的原因及解决办法
2012-09-29 11:27 75291.Frameset导致Cookies和Session丢失 ... -
java synchronized详解
2012-09-29 11:28 818来源:http://www.cnblogs.com/GnagW ... -
长连接与短连接
2012-09-29 11:29 1039来源:http://www.cnblogs.com ... -
java实时监测文件夹的变化,允许多用户同时访问,完成文件转移
2012-10-04 09:26 1189来源:http://www.189works.com/arti ... -
jndi调用时,各种应用服务器InitialContext的写法
2012-09-27 11:12 945调用ejb时,如果客户端和ejb不在同一个jvm,就要 ... -
jvm字节码执行引擎
2012-08-16 12:25 1065一. 运行时栈帧结构 1. 栈帧是用于支持虚拟机进行方法调用 ... -
ClassWorking技术
2012-08-16 12:25 1371ClassWorking技术 IBM所提出的,动态地监测、修 ... -
动态加载class文件
2012-08-16 12:26 8581.参考老外: public class ClassPat ... -
dbcp连接池实现
2012-08-09 13:10 1641dbcp连接池实现commons DBCP 配置参数简要说明 ... -
常用jar包之commons-beanutils使用
2012-08-20 14:07 1456核心提示:Jakarta Commons 项目提供了相当丰富的 ... -
aop详解
2012-08-09 13:09 1333使用Spring进行面向切面 ... -
Dwr2+Struts2+Spring2.5+Hibernate3整合
2012-08-08 12:33 9621.//如果不用,启动时不会出错,但使用Dwr时,会抛出异常: ... -
AOP面向编程的使用场合
2012-08-07 20:45 975AOP(Aspect-Oriented Programming ... -
23种设计模式详解
2012-08-08 13:41 1367Java中23种设计模式 目录 1. 设计模式 3 1. ...
相关推荐
Quartz的核心特性包括可持久化的作业存储、集群支持以及丰富的API,使得它成为企业级应用中进行定时任务调度的理想选择。 在使用Quartz-Scheduler时,首先需要在项目的`pom.xml`文件中添加对应的依赖。以下是一个...
- **集群支持**:Quartz Scheduler可以在集群环境中工作,确保即使部分节点失败,作业也能得到正确的调度和执行。 - **高性能**:通过高效的内部架构设计,Quartz Scheduler能够在高并发环境下保持稳定的性能表现。 ...
- **集群支持**:Quartz可以在多台服务器上进行分布式调度,确保任务在集群中的任何节点失败时仍能执行。 - **持久化**:任务和触发器的状态可以持久化到数据库,即使服务器重启也不会丢失已安排的任务。 - **监控与...
- 初始化SQL语句执行后,还需确保Quartz的配置文件(如`quartz.properties`)中的表名与创建的数据库表一致。 总之,Quartz 2.2.3的初始化SQL语句是搭建Quartz任务调度系统的重要环节,它们构建了存储任务调度数据...
- Job持久化:Quartz支持将Job和Trigger信息存储在数据库中,确保系统重启后任务能够恢复执行。 - Job状态管理:可以通过`JobExecutionContext`获取和设置Job的运行状态。 - 群组管理:Job和Trigger可以分组管理...
6. **集群支持**:Quartz可以配置在多台服务器上运行,形成一个集群,这样可以提高系统的可用性和容错性。当一台服务器出现问题时,其他服务器可以接管任务。 7. **API友好**:Quartz提供了简单易用的API,使得...
3. **集群支持**:Quartz 可以在多台服务器组成的集群中运行,当一台服务器故障时,任务可以被其他服务器接管,保证服务的高可用性。 4. **插件系统**:Quartz 具有强大的插件扩展能力,可以方便地添加新的功能或...
- **Spring 集成**:在 Spring 应用中,可以通过 XML 配置或 Java Config 方式来配置和初始化 Scheduler。 3. **数据库表结构** - Quartz 使用数据库存储 Jobs 和 Triggers,因此需要创建相应的数据库表。在提供...
2. **文档**:可能包括用户指南、API文档等,帮助开发者了解如何配置和使用Quartz。 3. **示例代码**:提供现成的代码示例,演示如何创建和调度Job,以及如何与数据库交互存储Job和Trigger信息。 4. **依赖库**:...
1. **配置 Scheduler**:创建 Scheduler 实例,配置相关的属性,如使用哪种 JobStore(如 JDBCJobStore)来存储 Job 和 Trigger。 2. **定义 Job**:编写 Job 类,实现 `execute()` 方法。 3. **创建 JobDetail**...
总结,Quartz作为强大的作业调度工具,能够有效地帮助开发者自动化执行周期性任务,提高应用的效率和智能化程度。通过深入学习和实践,我们可以充分利用Quartz的特性,构建高效、可靠的后台任务处理系统。
1. **初始化Scheduler**:通过`StdSchedulerFactory`获取Scheduler实例,配置相关的属性,如JobStore类型、线程池大小等。 2. **定义Job**:创建Job类,实现`Job`接口,并在`execute()`方法中编写任务逻辑。 3. **...
使用Quartz时,开发者首先需要配置Scheduler,指定JobStore类型(如RAMJobStore或JDBCJobStore),然后定义作业类(实现`org.quartz.Job`接口)和触发器(通过`org.quartz.Trigger`的子类)。最后,通过Scheduler...
- **集群支持**:多个 Quartz 节点可以组成集群,共享任务调度,提供高可用性。 2. **Quartz 配置** - **Scheduler**:作为 Quartz 的核心,Scheduler 负责管理和执行所有作业和触发器。可以通过 `...
Quartz是一个开源的作业调度框架,它为Java应用程序提供了强大的定时任务管理能力。...在实际开发中,根据项目需求选择合适的Trigger类型,结合Job和Scheduler的配置,能够有效地提升系统的自动化程度和效率。
2. **集群支持**:Quartz 可以在多台服务器上分布式部署,确保任务的高可用性和容错性。即使某个节点故障,任务仍能在其他节点上执行。 3. **持久化作业**:Quartz 可以将作业和触发器持久化到数据库,保证任务不会...
1. **集群支持**:Quartz-2.2加强了集群功能,允许多个Scheduler实例共享状态,即使在一个节点故障时,其他节点也能接管任务,确保高可用性。 2. **JDBC Job Store**:提供了一种将Job和Trigger存储在关系数据库中...
4. **集群支持**:在多服务器环境中,Quartz可以实现集群,确保任务的高可用性和负载均衡。 5. **作业存储与分组**:作业可以被组织在作业组中,便于管理和查找。同时,多个实例的同一作业也可以存在,通过不同的...
Quartz Scheduler 提供了集群特性,提供了 fail-over 和负载均衡。Quartz Scheduler 自有集群特性,在数据库持久保存的基础上。Terracotta 对 Quartz 的扩展,实现了一个集群能力,不需要终端数据库的支持。 监听器...
此外,Quartz支持集群,这意味着多个Scheduler实例可以协同工作,提供高可用性和负载均衡。在大型分布式系统中,这一点尤为重要。 通过深入学习和实践这个"quartz-1.7.3"压缩包的内容,我们可以熟练掌握Quartz的...