QuartzNet使用

quartz.config # You can configure your scheduler in either <quartz> configuration section
# or in quartz properties file
# Configuration section has precedence quartz.scheduler.instanceName = RemoteServer # configure thread pool info
quartz.threadPool.type = Quartz.Simpl.SimpleThreadPool, Quartz
quartz.threadPool.threadCount =
quartz.threadPool.threadPriority = Normal # job initialization plugin handles our xml reading, without it defaults are used
quartz.plugin.xml.type = Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz.Plugins quartz.plugin.xml.fileNames = ~/quartz_jobs.xml # export this server to remoting context
quartz.scheduler.exporter.type = Quartz.Simpl.RemotingSchedulerExporter, Quartz
quartz.scheduler.exporter.port =
quartz.scheduler.exporter.bindName = QuartzScheduler
quartz.scheduler.exporter.channelType = tcp
quartz.scheduler.exporter.channelName = httpQuartz
quartz.scheduler.exporter.rejectRemoteRequests = true
quartz_jobs.xml <?xml version="1.0" encoding="UTF-8"?> <!-- This file contains job definitions in schema version 2.0 format --> <job-scheduling-data xmlns="http://quartznet.sourceforge.net/JobSchedulingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0"> <processing-directives>
<overwrite-existing-data>true</overwrite-existing-data>
</processing-directives> <schedule> <!--cancelOrderJob测试 任务配置-->
<job>
<name>cancelOrderJob</name>
<group>ABC.OMS.Order</group>
<description>取消订单计划任务</description>
<job-type>QuartzTest.Jobs.CancelOrderJob,QuartzTest.Jobs</job-type>
<durable>true</durable>
<recover>false</recover>
</job>
<trigger>
<cron>
<name>cancelOrderTrigger</name>
<group>ABC.OMS.Order</group>
<job-name>cancelOrderJob</job-name>
<job-group>ABC.OMS.Order</job-group>
<start-time>--22T00::+:</start-time>
<cron-expression>/ * * * * ? </cron-expression>
</cron>
</trigger> </schedule>
</job-scheduling-data>
class Program
{
static void Main(string[] args)
{
// var properties = new NameValueCollection();
// properties["quartz.scheduler.instanceName"] = "RemoteServer";
// properties["quartz.threadPool.type"] = "Quartz.Simpl.SimpleThreadPool, Quartz";
// properties["quartz.threadPool.threadCount"] = "5";
// properties["quartz.threadPool.threadPriority"] = "Normal";
// properties["quartz.scheduler.exporter.type"] = "Quartz.Simpl.RemotingSchedulerExporter, Quartz";
// properties["quartz.scheduler.exporter.port"] = "555";
// properties["quartz.scheduler.exporter.bindName"] = "QuartzScheduler";
// properties["quartz.scheduler.exporter.channelType"] = "tcp";
// properties["quartz.scheduler.exporter.channelName"] = "httpQuartz";
// properties["quartz.scheduler.exporter.rejectRemoteRequests"] = "true";
//ISchedulerFactory schedFact = new StdSchedulerFactory(properties); ISchedulerFactory schedFact = new StdSchedulerFactory();
IScheduler sched = schedFact.GetScheduler().Result;
sched.Start(); IJobDetail cancelOrderJob = JobBuilder.Create<CancelOrderJob>()
.WithIdentity("cancelOrderJob", "ABC.OMS.Order")
.Build(); ITrigger cancelOrderTrigger = TriggerBuilder.Create()
.WithIdentity("cancelOrderTrigger", "ABC.OMS.Order")
.StartNow()
.WithSimpleSchedule(x => x
.WithIntervalInSeconds()
.RepeatForever())
.Build(); IJobDetail job1 = JobBuilder.Create<PaymentConfirmedJod>()
.WithIdentity("PaymentConfirmedJod", "group1")
.Build();
ITrigger trigger1 = TriggerBuilder.Create()
.WithIdentity("PaymentConfirmedTrigger", "group1")
.StartNow()
.WithSimpleSchedule(x => x
.WithIntervalInSeconds()
.RepeatForever())
.Build(); sched.ScheduleJob(cancelOrderJob, cancelOrderTrigger);
sched.ScheduleJob(job1, trigger1); System.Console.ReadKey();
}
}
namespace QuartzTest.Jobs
{
[DisallowConcurrentExecution] //设置JOB不允许并行执行
public class CancelOrderJob : IJob
{
System.Threading.Tasks.Task IJob.Execute(IJobExecutionContext context)
{
System.Console.WriteLine(string.Format("[{0}]订单已取消", DateTime.Now));
Thread.Sleep();
return System.Threading.Tasks.Task.CompletedTask;
}
}
}
QuartzNet使用的更多相关文章
- quartznet笔记
http://sourceforge.net/projects/quartznet/files/quartznet/
- [置顶] quartznet任务调度和消息调度(JAVA与C#版对比)
quartznet任务调度和消息调度 1. 作用 自动执行任务. 2. 下载地址 NET版本 JAVA版本 1下载 http://quartznet.sourceforge.net/downloa ...
- Asp.Net Core 基于QuartzNet任务管理系统
之前一直想搞个后台任务管理系统,零零散散的搞到现在,也算完成了. 这里发布出来,请园里的dalao批评指导! 废话不多说,进入正题. github地址:https://github.com/YANGK ...
- Asp.Net Core2.0 基于QuartzNet任务管理系统
Quartz.NET官网地址:https://www.quartz-scheduler.net/ Quartz.NET文档地址:https://www.quartz-scheduler.net/doc ...
- Asp.Net Core 基于QuartzNet任务管理系统(这是一篇用来水的随笔)
之前一直想搞个后台任务管理系统,零零散散的搞到现在,也算完成了. 废话不多说,进入正题. github地址:https://github.com/YANGKANG01/QuartzNetJob 一.项 ...
- SqlServer+Topshelf+Quartznet做集群,定时任务分布式处理
接触Quartznet之前,老东家用的是总监自己写的分布式任务框架,好用但是配置麻烦,unity,一个微软容器,配置节点错一个,整个使用到unity文件的项目全部跑不起来,这后果真的受不了... 目前 ...
- Net Core2.0 基于QuartzNet任务管理系统
Net Core2.0 基于QuartzNet任务管理系统 Quartz.NET官网地址:https://www.quartz-scheduler.net/ Quartz.NET文档地址:https: ...
- Topshelf + QuartzNet 实现挂载在 WIndows Services 中的定时任务
直接贴代码了: 首先我们可以把所有的 Job 放到一个单独的 DLL 中,好处是可以共享这些业务 Job.比如我们新建一个 QuartzNetDemo.WinService.Jobs 的类库. 然后, ...
- QuartzNet 远程管理持久化job 项目, 源码在Github..希望对大家有所帮助
文章目录 为了方便大家去学习 QuartzNet 与 CrystalQuartz 更多信息请点击链接查看 简介 结构图 为了方便大家去学习 QuartzNet 与 CrystalQuartz 更多信息 ...
随机推荐
- Codeforces 791C. Bear and Different Names 模拟构造
C. Bear and Different Names time limit per test:1 second memory limit per test:256 megabytes input:s ...
- python基础之Day5
一.基本概念 为什么要有数据: 计算机能够像人一样识别现实生活中的状态是因为计算机事先将数据存到了记忆中 为什么要分类型: 满足现实世界不同状态的需要 二.数据类型(研究定义,作用,常见操作) 1.整 ...
- Python之路(第二十三篇) 面向对象初级:静态属性、静态方法、类方法
一.静态属性 静态属性相当于数据属性. 用@property语法糖装饰器将类的函数属性变成可以不用加括号直接的类似数据属性. 可以封装逻辑,让用户感觉是在调用一个普通的数据属性. 例子 class R ...
- js jquery 取得周月年时间
function formatDate(date) { var myyear = date.getFullYear(); var mymonth = date.getMonth() + 1; var ...
- maven clean package 时出现Failed to read artifact descriptor for的问题解决
maven clean package 时出现Failed to read artifact descriptor for的问题 [ERROR] Failed to execute goal on p ...
- centos6.5虚拟机每次都要ifup eth0的解决办法
修改文件/etc/sysconfig/network-scripts/ifcfg-eth0把ONBOOT=no改ONBOOT=yes
- Java学习笔记:数据校验
在后台开发过程中,需要对参数进行校验. validation bean 是基于JSR-303标准开发出来的,使用注解的方式实现,是一套规范,可以实现参数的校验. Hibernate Validator ...
- 如何上传Packages到PyPI并批量抓取
1.如何上传包到PyPI ? 更新中... 2.批量抓取simple网站第三方模块 https://pypi.python.org/simple/ 3. 第三方模块的安装和使用 python set ...
- Redis (非关系型数据库) 数据类型 之 list列表类型
Redis列表是简单的字符串列表,按照插入顺序排序.你可以添加一个元素到列表的头部(左边)或者尾部(右边) list即可以作为“栈”也可以作为"队列". 操作: >lpush ...
- 网上流行的linux内核漫画