【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 ...
随机推荐
- hdu 4714 Tree2cycle 树形经典问题
发现今天没怎么做题,于是随便写了今天杭电热身赛的一题. 题目:给出一棵树,删边和添边的费用都是1,问如何删掉一些树边添加一些树边,使得树变成一个环. 分析:统计树的分支数.大概有两种做法: 1.直接d ...
- Session,Cookie,jsessionid,Url重写
在一些投票之类的场合,我们往往因为公平的原则要求每人只能投一票,在一些WEB开发中也有类似的情况,这时候我们通常会使用COOKIE来实现,例如如下的代码: < % cookie[]cookies ...
- 浅谈我眼中的ASP.NET MVC
坦白地说,学习MVC是前一段时间的事情了.但是,我当时虽然也实践过,却也不能很好的说出个所以然来.因此,也 一直没敢写点什么文字总结.最近,开始学习EF,也同时在使用MVC来结合EF实践增删改查.慢慢 ...
- 十三、Android学习笔记_Andorid控件样式汇总
<!-- 设置activity为透明 --> <style name="translucent"> <item name="android: ...
- C#去除HTML标签(转)
public static string ReplaceHtmlTag(string html, int length = 0) { string strText = System.Text.Regu ...
- IE10 下兼容性问题
昨天在IE10下遇到这样一个问题 用jquery 获取textarea里的值 其中内容这里包含HTML 用$("#Id").val().$("#Id").ht ...
- chromium浏览器开发系列第二篇:如何编译最新chromium源码
说一下为什么这么晚才发第二篇,上周和这周department的工作太多了,晚上都是十点半从公司出发,回家以后实在没有多余的精力去摸键盘了.所以请大家包涵! 上期回顾: chromium源码下载: 1. ...
- Objective C中nil/Nil/NULL的区别
nil:指向oc中对象的空指针 Nil:指向oc中类的空指针 NULL:指向其他类型的空指针,如一个c类型的内存指针 NSNull:在集合对象中,表示空值的对象 若obj为nil:[obj messa ...
- TouchAndGuest触摸事件和手势
//// nextViewController.m#import "nextViewController.h"#import "my.h"@interface ...
- Today’s dictation
A united nations expert on human rights in north korea has warned that the country's dictator, kim j ...