`
傅庆岩
  • 浏览: 91102 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

quartz配置db想关的,纯引用

阅读更多
http://www.quartz-scheduler.org/docs/configuration/ConfigJDBCJobStoreClustering.html
原文如上
要做个时间排程的东西,考虑参与db。记录一下

Quartz Enterprise Job Scheduler Configuration Reference
Configure Clustering with JDBC-JobStore
Quartz's clustering features bring both high availability and scalability to your scheduler via fail-over and load balancing functionality.

Clustering currently only works with the JDBC-Jobstore (JobStoreTX or JobStoreCMT), and essentially works by having each node of the cluster share the same database.

Load-balancing occurs automatically, with each node of the cluster firing jobs as quickly as it can. When a trigger's firing time occurs, the first node to acquire it (by placing a lock on it) is the node that will fire it.

Only one node will fire the job for each firing. What I mean by that is, if the job has a repeating trigger that tells it to fire every 10 seconds, then at 12:00:00 exactly one node will run the job, and at 12:00:10 exactly one node will run the job, etc. It won't necessarily be the same node each time - it will more or less be random which node runs it. The load balancing mechanism is near-random for busy schedulers (lots of triggers) but favors the same node that just was just active for non-busy (e.g. one or two triggers) schedulers.

Fail-over occurs when one of the nodes fails while in the midst of executing one or more jobs. When a node fails, the other nodes detect the condition and identify the jobs in the database that were in progress within the failed node. Any jobs marked for recovery (with the "requests recovery" property on the JobDetail) will be re-executed by the remaining nodes. Jobs not marked for recovery will simply be freed up for execution at the next time a related trigger fires.

The clustering feature works best for scaling out long-running and/or cpu-intensive jobs (distributing the work-load over multiple nodes). If you need to scale out to support thousands of short-running (e.g 1 second) jobs, consider partitioning the set of jobs by using multiple distinct schedulers (and hence multiple sets of tables (with distinct prefixes)). Using one scheduler forces the use of a cluster-wide lock, a pattern that degrades performance as you add more clients.




Enable clustering by setting the "org.quartz.jobStore.isClustered" property to "true". Each instance in the cluster should use the same copy of the quartz.properties file. Exceptions of this would be to use properties files that are identical, with the following allowable exceptions: Different thread pool size, and different value for the "org.quartz.scheduler.instanceId" property. Each node in the cluster MUST have a unique instanceId, which is easily done (without needing different properties files) by placing "AUTO" as the value of this property. See the info about the configuration properties of JDBC-JobStore for more information.

Never run clustering on separate machines, unless their clocks are synchronized using some form of time-sync service (daemon) that runs very regularly (the clocks must be within a second of each other). See http://www.boulder.nist.gov/timefreq/service/its.htm if you are unfamiliar with how to do this.
Never start (scheduler.start()) a non-clustered instance against the same set of database tables that any other instance is running (start()ed) against. You may get serious data corruption, and will definitely experience erratic behavior.
Example Properties For A Clustered Scheduler



#============================================================================
# Configure Main Scheduler Properties 
#============================================================================

org.quartz.scheduler.instanceName = MyClusteredScheduler
org.quartz.scheduler.instanceId = AUTO

#============================================================================
# Configure ThreadPool 
#============================================================================

org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 25
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.useProperties = false
org.quartz.jobStore.dataSource = myDS
org.quartz.jobStore.tablePrefix = QRTZ_

org.quartz.jobStore.isClustered = true
org.quartz.jobStore.clusterCheckinInterval = 20000

#============================================================================
# Configure Datasources 
#============================================================================

org.quartz.dataSource.myDS.driver = oracle.jdbc.driver.OracleDriver
org.quartz.dataSource.myDS.URL = jdbc:oracle:thin:@polarbear: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
  • 大小: 2.7 KB
分享到:
评论

相关推荐

    quartz quartz-1.8.6 dbTables 建表sql

    总之,"quartz quartz-1.8.6 dbTables" 提供了构建Quartz调度框架所需的数据库脚本,确保了任务调度的存储和恢复功能。通过理解和正确应用这些脚本,开发者可以充分利用Quartz的强大功能,创建和管理复杂的时间驱动...

    完整quartz配置大全

    OpenSymphony 的Quartz提供了一个比较完美的任务调度解决方案。  Quartz 是个开源的作业调度框架,为在 Java 应用程序中进行作业调度提供了简单却强大的机制。  Quartz中有两个基本概念:作业和触发器。作业是...

    关于spring中quartz的配置

    以下将详细介绍如何在Spring中配置Quartz以及相关知识点。 1. **引入依赖** 在开始配置之前,首先需要在项目的`pom.xml`或`build.gradle`文件中引入Quartz和Spring相关的依赖库。对于Maven项目,可以添加如下依赖...

    quartz 时间配置规则

    quartz 时间配置规则quartz 时间配置规则quartz 时间配置规则quartz 时间配置规则quartz 时间配置规则quartz 时间配置规则

    Spring Quartz如何动态配置时间

    Spring Quartz 动态配置时间 Spring Quartz 是一个功能强大的任务调度框架,广泛应用于 Java 企业级应用程序中。其中一个重要的功能便是动态配置时间,触发相应的任务。在本文中,我们将讨论如何使用 Spring Quartz...

    quartz配置含表达式的事务以及集群上quartz配置

    在配置Quartz时,有时我们需要结合表达式来控制事务,同时在集群环境下,配置Quartz以确保高可用性和任务的一致性。 首先,我们来看如何在Quartz中配置含表达式的事务。在Quartz中,任务的执行是在一个事务上下文中...

    springboot整合quartz定时任务yml文件配置方式

    Spring Boot与Quartz的结合提供了便捷的配置方式,特别是通过YAML(YAML Ain't Markup Language)配置文件,使得配置更加直观和灵活。以下将详细介绍如何在Spring Boot应用中使用YAML文件配置Quartz定时任务,以及...

    quartz时间配置表达式生成工具

    quartz时间配置表达式生成工具,通界面配置生成表达式

    SpringBoot2.x quartz yml完整配置

    添加公众号:猿有一技,回复 :Spring ,获取SpringBoot2.x quartz yml完整配置

    转:spring多个定时任务quartz配置

    本文将深入探讨如何在Spring中配置多个Quartz定时任务,并结合`quartz.properties`文件进行详细讲解。 首先,我们需要理解Quartz的基本概念。Quartz是开源的作业调度框架,允许应用程序在特定时间执行任务。它支持...

    Spring中的Quartz配置-Spring-定时器-java定时器.doc

    Spring 中的 Quartz 配置-Spring 定时器-java 定时器 在 Spring 框架中,Quartz 是一个非常流行的开源作业调度器,可以实现任务的定时执行。在本篇文章中,我们将讨论如何在 Spring 中配置 Quartz,以实现 Java ...

    quartz配置

    quartz 配置文件 ,很详细,带注释 ,我觉得挺好的,可以参考,够了,

    Quartz 数据库动态配置

    这就是“Quartz数据库动态配置”所解决的问题。 Quartz通过将作业(Jobs)和触发器(Triggers)的信息存储在数据库中,实现了配置的动态化。这样,我们可以在不重启应用的情况下,通过修改数据库中的表来添加、删除...

    spring多个定时任务quartz配置

    本文将深入探讨如何在Spring中配置Quartz以实现多个定时任务。 首先,我们需要理解Quartz的基本概念。Quartz是一个开源的工作调度框架,它允许应用程序定义作业(Jobs)和触发器(Triggers),以在指定的时间执行...

    对于Quartz.net 3.0.7.0(目前最高版本)的使用:能过配置文件实现工作调整

    在描述中提到的问题是关于如何在3.x版本中通过`quartz_jobs.xml`配置文件实现作业调度,这在许多教程中可能较少被提及,因为早期版本的Quartz.NET更倾向于使用XML配置,而新版本则倾向于使用代码配置或者混合方式。...

    Spring -Quartz的配置

    本文将深入探讨如何在Spring框架中配置Quartz,以便利用其功能来执行计划的任务。 首先,我们需要理解Spring与Quartz结合的基本原理。Spring通过提供一个Quartz的JobFactory,可以集成Quartz到Spring容器中,这样...

    Quartz_for_DB(MySQL、SQLServer).zip

    在"Quartz_for_DB(MySQL、SQLServer).zip"这个压缩包中,包含的是Quartz与数据库集成的示例,特别支持MySQL和SQL Server两大常见的关系型数据库系统。 首先,我们来了解一下Quartz的核心概念: 1. **Job**:代表...

    web工程quartz的配置实例

    Quartz的配置主要通过`quartz.properties`文件进行。该文件中可以设置数据库连接、线程池大小、Job存储方式等。例如: ``` org.quartz.scheduler.instanceName = MyScheduler org.quartz.threadPool.class = org...

    spring-quartz配置

    spring-quartz的标准配置文件

    Quartz CronTrigger配置说明

    ### Quartz CronTrigger配置详解 #### 一、CronTrigger简介 CronTrigger 是 Quartz 调度器中一种非常强大的任务触发机制,它基于类似于 Unix cron 的表达式来定义任务的执行时间。CronTrigger 表达式由七个或八个...

Global site tag (gtag.js) - Google Analytics