QUARTZ系列之一-基础概念(Scheduler/Job/JobDetail/Trigger)
摘抄自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)的更多相关文章
- .NET技术面试题系列(1) 基础概念
这是.NET技术面试题系列第一篇,今天主要分享基础概念. 1.简述 private. protected. public.internal 修饰符的访问权限 private : 私有成员, 在类的内部 ...
- 快速入门系列--WCF--01基础概念
转眼微软的WCF已走过十个年头,它是微软通信框架的集大成者,将之前微软所有的通信框架进行了整合,提供了统一的应用方式.记得从自己最开始做MFC时,就使用过Named Pipe命名管道,之后做Winfo ...
- 快速入门系列--TSQL-01基础概念
作为一名程序员,对于SQL的使用算是基础中的基础,虽然也写了很多年的SQL,但常常还是记不清一些常见的命令,故而通过一篇博文巩固相关的记忆,并把T-SQL本身的一些新特性再进行一次学习. 首先回顾基础 ...
- angular 2+ 变化检测系列一(基础概念)
什么是变化检测? 变化检测的基本功能就是获取应用程序的内部状态(state),并且是将这种状态对用户界面保持可见.状态可以是javascript中的任何的数据结构,比如对象,数组,(数字,布尔,字符串 ...
- zabbix学习系列之基础概念
触发器 概念 "监控项"仅负责收集数据,而通常收集数据的目的还包括在某指标对应的数据超出合理范围时给相关人员发送警告信息,"触发器"正式英语为监控项所收集的数据 ...
- Quartz Job scheduling 基础实现代码
Quartz 集成在 SpringBoot 中分为 config.task.utils.controller 和 MVC 的三层即 controller.service.dao 和 entity. c ...
- 【优化技术专题】「温故而知新」基于Quartz系列的任务调度框架的动态化任务实现分析
不提XXLJOB或者其他的调度框架,就看我接触的第一个任务调度框架Quartz(温故而知新) Quartz的动态暂停 恢复 修改和删除任务 实现动态添加定时任务,先来看一下我们初步要实现的目标效果图, ...
- MongoDB入门系列(一):基础概念和安装
概述 MongoDB是目前非常流行的一种非关系型数据库,作为入门系列的第一篇本篇文章主要介绍Mongdb的基础概念知识包括命名规则.数据类型.功能以及安装等. 环境: OS:Windows Versi ...
- Quartz系列(一):基础介绍
新建一个.NET Core控制台项目,NuGet引用Quartz引用. class Program { static void Main(string[] args) { var task = Tas ...
随机推荐
- flask中自定义过滤器
第一种方法: 1,第一步:自定义过滤器函数 # 自定义一个函数,将list里面的数据进行排序 def list_sort(list) return list.sort() 2.第二步:注册过滤器 第一 ...
- Github最简单实用的Git命令指南
create a new repository on the command line echo "# test" >> README.md git init gi ...
- configparse模块和hashlib模块
# import configparser # # config = configparser.ConfigParser() #config = {} # config['DEFAULT'] = {' ...
- c——根据天数输出日期
<c语言程序设计>(第三版)何钦铭 P190 #include<stdio.h> void month_day(int year,int yearday,int *pmonth ...
- Span<T>和ValueTuple<T>性能是.Net Core非常关键的特性
Span<T>和ValueTuple<T> 性能是.Net Core一个非常关键的特性,今天我们重点研究一下ValueTuple<T>和Span<T>. ...
- linux_wget 使用
一.Linux之安装软件之wget安装方法使用 https://www.cnblogs.com/peida/archive/2013/03/18/2965369.html
- PythonStudy——数据类型 Type of data
数据类型:信息存在的状态为什么要来描述事物的具体状态:不同的事物需要不同的状态加以描述可以达到描述的最优化 python中有哪些常见的数据类型 1.整型 num = 10000000000000000 ...
- Nginx自动安装脚本
添加一个install_nginx.sh脚本 版本一:(以下脚本为在线自动化安装) #!/bin/bash mkdir /soft cd /soft wget -c http://nginx.org/ ...
- C++对象的构造、析构与拷贝构造
今天下午在研究虚函数的时候遇到了一个问题,觉得很有意思,记录一下. 先看代码: class Base { public: Base(int value) { m_nValue = value; cou ...
- dos2unix 批量转化文件
在windows和linux双平台下开发,同时也用git作为同步工具,但前期没有注意,导致很多文件使用windows下的换行符CRLF 参考资料了解dos2unix可以转化格式. 但有个问题,虽然可以 ...