【quartz】 数据库方式管理任务
public static void Run(bool inClearJobs, bool inScheduleJobs)
{
var properties = new NameValueCollection();
properties["quartz.scheduler.instanceName"] = "测试任务"; //调度标识名 集群中每一个实例都必须使用相同的名称
properties["quartz.scheduler.instanceId"] = "instance_one"; //ID设置为自动获取 每一个必须不同
properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
properties["quartz.threadPool.threadCount"] = "";//线程数量
properties["quartz.threadPool.threadPriority"] = "Normal";//线程优先级
properties["quartz.jobStore.misfireThreshold"] = ""; //容许的最大作业延长时间
properties["quartz.jobStore.type"] = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz";//AdoJobStore
properties["quartz.jobStore.useProperties"] = "false";//设置为TRUE不会出现序列化非字符串类到 BLOB 时产生的类版本问题
properties["quartz.jobStore.dataSource"] = "default";//数据库别名 随便取
properties["quartz.jobStore.tablePrefix"] = "QRTZ_";//指定所使用的数据库表前缀
properties["quartz.jobStore.clustered"] = "true";//加入集群
properties["quartz.jobStore.driverDelegateType"] = "Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz";//数据库类型
properties["quartz.dataSource.default.connectionString"] = @"Server=10.32.11.23,14339;database=YintaiService;uid=erpdev;pwd=Test_2jaJk)@aA2";//数据库配置连接串
properties["quartz.dataSource.default.provider"] = "SqlServer-20";// framework2.0以上 ISchedulerFactory sf = new StdSchedulerFactory(properties);
IScheduler sched = sf.GetScheduler(); if (inClearJobs)
{
sched.Clear();//清除数据
} //注入一个任务
//jobdatamap可以持久化到数据库,但是在运行期间改变了jobdatamap中的某个属性时,这个新值不能持久化到数据库,也就等于是没法修改。
if (inScheduleJobs)
{
string schedId = sched.SchedulerInstanceId;
int count = ;
IJobDetail job = JobBuilder.Create<HelloJob>()
.WithIdentity("job_" + count, schedId) // put triggers in group named after the cluster node instance just to distinguish (in logging) what was scheduled from where
.RequestRecovery() // ask scheduler to re-execute this job if it was in progress when the scheduler went down...
.Build();
ISimpleTrigger trigger = (ISimpleTrigger)TriggerBuilder.Create()
.WithIdentity("triger_" + count, schedId)
.StartAt(DateBuilder.FutureDate(, IntervalUnit.Second))
.WithSimpleSchedule(x => x.WithRepeatCount().WithInterval(TimeSpan.FromSeconds()))
.Build();
count++;
sched.ScheduleJob(job, trigger);
} sched.Start(); }
【quartz】 数据库方式管理任务的更多相关文章
- spring boot+Quartz+数据库存储
SpingBoot+Quartz+数据库存储 1.Spring整合Quartz 2.读取数据库中表达式启动定时任务1(每5s执行) 3.更改定时任务状态(启用/禁用),定时任务1停止 4.读取数据库中 ...
- .net core quartz job作业调度管理组件
定时作业对于多数系统来说,都会用到,定时作业的实现方式可以有多种方式,简单的方式用Timer就可以实现,但是达不到通用的效果,本文采用Quartz基础组件来搭建一套企业通用的作业调度管理服务,希望对于 ...
- DB2 9.5 数据库分区管理及应用实践
DB2 数据库分区是 DB2 企业版 DPF(Data Partitioning Feature)选件提供的,它主要用来为大规模数据处理.高并发数据访问提供支持.DB2 数据库分区采用 Share-n ...
- Spring整合Hibernate:1、annotation方式管理SessionFactory
1.在applicationContext.xml文件中初始化SessionFactory(annotation方式) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 ...
- MongoDB Wiredtiger存储引擎实现原理——Copy on write的方式管理修改操作,Btree cache
转自:http://www.mongoing.com/archives/2540 传统数据库引擎的数据组织方式,一般存储引擎都是采用 btree 或者 lsm tree 来实现索引,但是索引的最小单位 ...
- (转)使用Spring注解方式管理事务与传播行为详解
http://blog.csdn.net/yerenyuan_pku/article/details/52885041 使用Spring注解方式管理事务 前面讲解了怎么使用@Transactional ...
- 数据库智能管理助手-CloudDBA
摘要:阿里云CloudDBA主要分为离线分析和在线分析两种功能.帮助用户节省成本,定位问题,分析原因并推荐解决方法.CloudDBA可以做到实时诊断,离线诊断和SQL优化.并且通过MySQL的参数调优 ...
- Database基础(一):构建MySQL服务器、 数据库基本管理 、MySQL 数据类型、表结构的调整
一.构建MySQL服务器 目标: 本案例要求熟悉MySQL官方安装包的使用,快速构建一台数据库服务器: 安装MySQL-server.MySQl-client软件包 修改数据库用户root的密码 确认 ...
- Spring-Security (学习记录四)--配置权限过滤器,采用数据库方式获取权限
目录 1. 需要在spring-security.xml中配置验证过滤器,来取代spring-security.xml的默认过滤器 2. 配置securityMetadataSource,可以通过ur ...
随机推荐
- ionic 项目的启动屏幕
首先要做好图片,图片的大小最好是192px*192px(icon.png).2208px*2208px(splash.png); 然后在APP项目中建立一个新文件夹,resources,将准备好的两张 ...
- CF 118E Bertown roads 桥
118E Bertown roads 题目:把无向图指定边的方向,使得原图变成有向图,问能否任意两点之间互达 分析:显然如果没有桥的话,存在满足题意的方案.输出答案时任意从一个点出发遍历一遍即可. 求 ...
- Table of Contents - Jersey
Jersey 1.19.1 Getting Started Get started with Jersey using the embedded Grizzly server Get started ...
- LINQ to SQL 语句(2)之 Select/Distinct
LINQ to SQL 语句(2)之 Select/Distinct [1] Select 介绍 1 [2] Select 介绍 2 [3] Select 介绍 3 和 Distinct 介绍 Se ...
- AMQ学习笔记 - 05. 客户端模板化
概述 客户端编程模型中,大部分的步骤都是相同的.将相同的部分做成模板,将不同的部分预留接口,实现者就只需要针对不同的部分提供实现. 设计 类图 发送方客户端 说明: 基于模板的思想,SendTempl ...
- MiZ702学习笔记13——ZYNQ通过AXI-Lite与PL交互
在<MiZ702学习笔记7——尝试自制带总线IP>,我曾提到了AXI4-Lite的简单用法,驱动了下流水灯,只涉及到了写总线.今天,我想利用之前的VGA模块,将AXI4-Lite的读写都应 ...
- 20140213-想念是while里的死循环
// stdafx.h : 标准系统包含文件的包含文件,// 或是经常使用但不常更改的// 特定于项目的包含文件// #pragma once#include "targetver.h&qu ...
- pop()实现逐个删除数组最后一位并输出
使用pop()循环输出数组的最后一个元素 var a = []; a.push(1);a.push(3.1415926);a.push("number");a.push(" ...
- CP30 ---DataSource连接池的创建过程
1.参看CP30文档quickStart 如下具体创建步骤 public DataSource getDs() throws Exception { //创建连接池对象 ComboPooledData ...
- hibernate get VS load
1. 执行get方法:会立即加载对象 而执行load方法,若不适用该对象,则不会立即执行查询操作,而返回一个代理对象 get立即检索,load延迟检索 2. load方法可能 ...