摘抄自quartz官方文档:

The key interfaces of the Quartz API are:

  • Scheduler - the main API for interacting with the scheduler.  (quartz提供的用来和调度器交互的API)
  • Job - an interface to be implemented by components that you wish to have executed by the scheduler.(你希望被调度的任务体)
  • JobDetail - used to define instances of Jobs.  (用来定义任务实例)
  • Trigger - a component that defines the schedule upon which a given Job will be executed. (定义了Job运行的调度时间表(即schedule,注意与scheduler的区别))
  • JobBuilder - used to define/build JobDetail instances, which define instances of Jobs.(job构建器,quartz特有的DSL)
  • TriggerBuilder - used to define/build Trigger instances.(trigger构建器,quartz特有的DSL)

Quartz provides “builder” classes that define a Domain Specific Language (or DSL, also sometimes referred to as a “fluent interface”).

quartz定义了一套DSL,其实也就是一套bulider模式。值得注意的是,JobBuilder的doc中有这样一句:

The builder will always try to keep itself in a valid state, with reasonable defaults set for calling build() at any point. 

For instance if you do not invoke <i>withIdentity(..)</i> a job name will be generated for you.

builder会努力使自己处于有效的状态。

Scheduler:

scheduler:调度器,没啥好讲的。various “ScheduleBuilder” classes build出各种不同的scheduler。

Trigger:

1.1 SimpleTrigger:

1.2 CronTrigger:

1.2.1.特点:recurs based on calendar-like notions,such as "every Friday at noon","every weekday and 9:30 am",even "every 5 minutes between 9:00 am and 10:00 am on every Monday, Wednesday and Friday during January".

1.2.2 CRON表达式:自己百度

1.2.3 使用:

using TriggerBuilder (for the trigger’s main properties) and CronScheduleBuilder (for the CronTrigger-specific properties).

To use these builders in a DSL-style, use static imports:

import static org.quartz.TriggerBuilder.*;
import static org.quartz.CronScheduleBuilder.*;
import static org.quartz.DateBuilder.*:

Build a trigger that will fire every other minute, between 8am and 5pm, every day:

  trigger = newTrigger()
.withIdentity("trigger3", "group1")
.withSchedule(cronSchedule("0 0/2 8-17 * * ?"))
.forJob("myJob", "group1")
.build();

1.2.4 Misfire说明:

Misfire Instruction Constants of CronTrigger:

MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY                                   // java doc中未见此字段,但是官方文档有此字段
MISFIRE_INSTRUCTION_DO_NOTHING = 2 // 1. 更新next-fire-time;2.本次不执行
MISFIRE_INSTRUCTION_FIRE_NOW = 1 // to be fired now

Note:1.也有Trigger.MISFIRE_INSTRUCTION_SMART_POLICY字段,当作MISFIRE_INSTRUCITON_FIRE_NOW 处理。

2.行为的具体细节参考CronTrigger.updateAfterMisfire()方法

3.使用方式:放到schedule中定义即可:

cronSchedule("0 0/2 8-17 * * ?")
..withMisfireHandlingInstructionFireAndProceed()

QUARTZ系列之一-基础概念(Scheduler/Job/JobDetail/Trigger)的更多相关文章

  1. .NET技术面试题系列(1) 基础概念

    这是.NET技术面试题系列第一篇,今天主要分享基础概念. 1.简述 private. protected. public.internal 修饰符的访问权限 private : 私有成员, 在类的内部 ...

  2. 快速入门系列--WCF--01基础概念

    转眼微软的WCF已走过十个年头,它是微软通信框架的集大成者,将之前微软所有的通信框架进行了整合,提供了统一的应用方式.记得从自己最开始做MFC时,就使用过Named Pipe命名管道,之后做Winfo ...

  3. 快速入门系列--TSQL-01基础概念

    作为一名程序员,对于SQL的使用算是基础中的基础,虽然也写了很多年的SQL,但常常还是记不清一些常见的命令,故而通过一篇博文巩固相关的记忆,并把T-SQL本身的一些新特性再进行一次学习. 首先回顾基础 ...

  4. angular 2+ 变化检测系列一(基础概念)

    什么是变化检测? 变化检测的基本功能就是获取应用程序的内部状态(state),并且是将这种状态对用户界面保持可见.状态可以是javascript中的任何的数据结构,比如对象,数组,(数字,布尔,字符串 ...

  5. zabbix学习系列之基础概念

    触发器 概念 "监控项"仅负责收集数据,而通常收集数据的目的还包括在某指标对应的数据超出合理范围时给相关人员发送警告信息,"触发器"正式英语为监控项所收集的数据 ...

  6. Quartz Job scheduling 基础实现代码

    Quartz 集成在 SpringBoot 中分为 config.task.utils.controller 和 MVC 的三层即 controller.service.dao 和 entity. c ...

  7. 【优化技术专题】「温故而知新」基于Quartz系列的任务调度框架的动态化任务实现分析

    不提XXLJOB或者其他的调度框架,就看我接触的第一个任务调度框架Quartz(温故而知新) Quartz的动态暂停 恢复 修改和删除任务 实现动态添加定时任务,先来看一下我们初步要实现的目标效果图, ...

  8. MongoDB入门系列(一):基础概念和安装

    概述 MongoDB是目前非常流行的一种非关系型数据库,作为入门系列的第一篇本篇文章主要介绍Mongdb的基础概念知识包括命名规则.数据类型.功能以及安装等. 环境: OS:Windows Versi ...

  9. Quartz系列(一):基础介绍

    新建一个.NET Core控制台项目,NuGet引用Quartz引用. class Program { static void Main(string[] args) { var task = Tas ...

随机推荐

  1. vue2.0 父子组件通信 兄弟组件通信

    父组件是通过props属性给子组件通信的来看下代码: 父组件: <parent> <child :child-com="content"></chil ...

  2. message box

    QMessageBox 弹出框上的按钮设置为中文   Qt 默认的弹出框上的按钮式英文,虽然也知道是什么意思,但终究不如中文看着顺眼. QMessageBox box(QMessageBox::War ...

  3. c#利用ApplicationContext类 同时启动双窗体的实现

    Application类(位于System.Windows.Forms命名空间)公开了Run方法,可以调用该方法来调度应用程序进入消息循环.Run方法有三个重载 1.第一个重载版本不带任何参数,比较少 ...

  4. 使用FileZilla连接时超时,无法连接到服务器

    更改一下加密方式,就是不用TLS,用相对不安全方式的(可选项)  腾讯云就是这样的,

  5. OpenResty 最佳实践 lua与nginx的结合 --引用自https://moonbingbing.gitbooks.io/openresty-best-practices/content/

    系统的说明了lua在nginx上的开发 请大家到源址查看 OpenResty最佳实践

  6. Hadoop-HBASE 热添加新节点

    Hadoop-HBASE 热添加新节点 环境:192.168.137.101 hd1192.168.137.102 hd2192.168.137.103 hd3192.168.137.104 hd4四 ...

  7. 【RestTemplete】使用RestTemplete传Json或者 {} 报错--解决

    https://jira.spring.io/browse/SPR-9220?focusedCommentId=76760&page=com.atlassian.jira.plugin.sys ...

  8. 创建一个HTTP接口测试

    jmeter Apache JMeter是Apache组织开发的基于Java的压力测试工具. Apache jmeter 可以用于对静态的和动态的资源(文件,Servlet,Perl脚本,java 对 ...

  9. maven打包时报错:-source 1.5 中不支持 diamond 运算符

    报错现象: 解决方法: 在pom文件中加入下面依赖 <build> <plugins> <plugin> <groupId>org.apache.mav ...

  10. [转][C#]加密解密类

    { public static class Crypter { private static string FDefaultPassword = typeof(Crypter).FullName; p ...