【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 ...
随机推荐
- 18个有用的 .htaccess 文件使用技巧
.htaccess 是 Web 服务器 Apache 中特有的一个配置文件,操控着服务器上的许多行为,我们可以利用它来做许多事情,例如:设置访问权限,网址重定向,等等.本文向大家展示18条 .htac ...
- angularjs表格方式显示数据
<table> <tr ng-repeat="x in names"> <td>{{ x.Name }}</td> <td&g ...
- [转]在WPF中使用WinForm控件方法
本文转自:http://blog.csdn.net/lianchangshuai/article/details/6415241 下面以在Wpf中添加ZedGraph(用于创建任意数据的二维线型.条型 ...
- 从Setting.settings到Resource.resx
之前由于经验不足,将常用的App提示信息串(string)放置在了配置文件中(*.Settings).目前需要将App国际化,对这些信息的翻译有两个途径: 直接翻译,将参数中的提示信息串用英文或者其他 ...
- hdu 4403 简单搜索
思路:分等号左边和右边进行搜索 #include<iostream> #include<cstdio> #include<cstring> #include< ...
- 转 : React Native 开发之 IDE 选型和配置
转:https://mp.weixin.qq.com/s?__biz=MzA3ODg4MDk0Ng==&mid=2651112392&idx=1&sn=135e29ddde30 ...
- ASP.NET不拖控件教程(1)-认识JSON
我讲讲脱离ASP.NET控件必备的一步,JSON和使用JQuery获取JSON吧! 高手跳过,写给学习中的人的.这篇帖子是假设你会使用JQuery(JQ这么普及,应该不至少没学过吧!真没学过以后再开帖 ...
- android:launchMode概述
android:launchMode An instruction on how the activity should be launched. There are four modes that ...
- JavaScript之放大镜效果2
在放大图片效果的同时,我们怎么原图和放大窗体增加间隔呢? 我们只需应用一个table就行了: 源码上: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML ...
- Cocos2d-x坐标系介绍
在图形图像和游戏应用开发中坐标系是非常重要的,我们在Android和iOS等平台应用开发的时候使用的二维坐标系它的原点是在左上角的.而在Cocos2d-x坐标系中它原点是在左下角的,而且Cocos2d ...