quartz 分布式配置
来源:互联网 发布:阿里云手机云空间 编辑:程序博客网 时间:2024/05/16 07:21
1.背景
当quartz部署在分布式环境下时,希望同一时刻同一个job只运行在一个节点上。
2.模拟场景 工程目录下 有job1 job2 job3 分别部署在 node1 node2 node3上。
不采用分布式集群时 在每个节点 job1 job2 job3都执行。node1 同时执行三个job node2同时执行三个job node3同时执行三个job。(共9个job在执行。)
采用分布式集群配置后 job1 job2 job3 在这三个节点同一时刻一共有job1 job2 job3在执行。共三个job执行。
3分布式配置方式(持久化到数据库中支持主流数据库mysql为例)
1.官网下载quartz-2.2.2.jar 解压。
docs\dbTables 目录下找到 tables_mysql.sql 执行在自己的mysql中。
2创建java普通工程。
依赖包lib下
c3p0-0.9.1.1.jar
log4j-1.2.16.jar
quartz-2.2.2.jar
quartz-jobs-2.2.2.jar
slf4j-api-1.7.7.jar
slf4j-log4j12-1.7.7.jar
3 配置quartz.properties
examples\example13\instance1.properties 改名quartz.properties 拷贝到工程src目录下
#============================================================================
# Configure Main Scheduler Properties
#============================================================================
org.quartz.scheduler.instanceName: TestScheduler
org.quartz.scheduler.instanceId: instance_one
org.quartz.scheduler.skipUpdateCheck: true
#============================================================================
# Configure ThreadPool
#============================================================================
org.quartz.threadPool.class: org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount: 5
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.StdJDBCDelegate
org.quartz.jobStore.useProperties=false
org.quartz.jobStore.dataSource=myDS
org.quartz.jobStore.tablePrefix=QRTZ_
org.quartz.jobStore.isClustered=true
#============================================================================
# Other Example Delegates
#============================================================================
#org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.DB2v6Delegate
#org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.DB2v7Delegate
#org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.DriverDelegate
#org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.HSQLDBDelegate
#org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.MSSQLDelegate
#org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.PointbaseDelegate
#org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
#org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
#org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.WebLogicDelegate
#org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.oracle.OracleDelegate
#org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.oracle.WebLogicOracleDelegate
#============================================================================
# Configure Datasources
#============================================================================
org.quartz.dataSource.myDS.driver:com.mysql.jdbc.Driver
org.quartz.dataSource.myDS.URL: jdbc:mysql://localhost:3306/quartz
org.quartz.dataSource.myDS.user: root
org.quartz.dataSource.myDS.password: root
org.quartz.dataSource.myDS.maxConnections: 5
org.quartz.dataSource.myDS.validationQuery: select 0
#============================================================================
# Configure Plugins
#============================================================================
#org.quartz.plugin.shutdownHook.class: org.quartz.plugins.management.ShutdownHookPlugin
#org.quartz.plugin.shutdownHook.cleanShutdown: true
#org.quartz.plugin.triggHistory.class: org.quartz.plugins.history.LoggingJobHistoryPlugin
4 把examples\example13\log4j.xml 放在src目录下
就这么简单大功告成!!qq:263090670 有问题可以交流.
- quartz 分布式配置
- spring+quartz分布式配置
- 分布式服务下Quartz任务框架配置
- Quartz+Spring 分布式定时任务调度(二)- 集群配置
- SpringCloud(第 054 篇)简单 Quartz-Cluster 微服务,采用注解配置 Quartz 分布式集群
- Quartz分布式任务(二)
- springboot+quartz分布式
- quartz配置
- Quartz 配置
- quartz 配置
- quartz配置
- Quartz(04) Quartz 基本配置
- Quartz和分布式定时任务
- Quartz分布式调试任务(一)
- quartz配置总结
- spring+quartz配置
- spring+quartz配置
- Spring2 quartz 配置
- [NOIP2010]导弹拦截 T3 贪心
- 打印1到最大的N位数
- Android Studio之版本管理工具Git (图文教程)
- RevitAPI: 设置管件族的连接件的半径属性抛异常 - 如何获取关联族参数
- html 基础标签知识
- quartz 分布式配置
- 我的里程碑~~
- 《Node.js入门》CentOS 6.5下Node.js Web开发环境搭建笔记
- socket的半包,粘包与分包的问题
- Android的手势操作识别
- 国嵌数据结构视频笔记
- error: stray ‘\302’ in program 处理
- 数据结构--1、线性表
- 关于编译性语言、解释性语言和脚本语言,动态语言,静态语言的区别