quartz

Topshelf+Quartz在.Net Core框架下的实现

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 20:08:12
  在我们日常开发工作中,经常会运用到Quartz+Topshelf组件的组合来开发一些定时任务。那么在.Net Core下如何去使用呢?我自己尝试搭建了一个测试项目,过程中遇到了以下一些问题: Quartz 配置文件及版本问题。我们知道Quartz有2个配置文件,quartz.config和quartz.job.xml。前者负责组件初始化配置,后者负责job和triggle的配置。刚开始我是直接把framework下的配置文件直接拿过来用的,启动直接报错。主要问题在quartz.config quartz.plugin.xml.type = Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz 这一段上。原因Quartz最新版本已经将Plugin模块单独剥离出一个独立的DLL,这里的引用也要变化。需要Nuget上下载Quartz.Plugins组件,并将上一段改成 quartz.plugin.xml.type = Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz.Plugins DI问题。为了贴合.Net Core DI精神,我们也要来实现Console程序的DI功能。第一个问题是Job如何DI?首先我们需要自己去实现JobFactory

Quartz学习笔记:基础知识

泪湿孤枕 提交于 2019-12-03 14:31:44
Quartz学习笔记:基础知识 引入Quartz 关于Quartz   Quartz 是一个完全 由 Java 编写 的 开源作业调度框架 ,为在 Java 应用程序中进行作业调度提供了简单却强大的机制。      关于任务调度,Java.util.Timer是最简单的一种实现任务调度的方法,简单的使用如下: import java.util.Timer; import java.util.TimerTask; public class TimerTest { public static void main(String[] args) { Timer timer = new Timer(); long delay = 1000; //延时多少秒开始执行 long period =1000; //执行周期 timer.schedule(new MyTask(),delay,period); } } class MyTask extends TimerTask{ @Override public void run() { System.out.println("Hello World"); } }    来源: https://www.cnblogs.com/MrSaver/p/11799966.html

通过TopShelf简单创建windows service

夙愿已清 提交于 2019-12-03 14:03:54
目前很多项目都是B/S架构的,我们经常会用到webapi、MVC等框架,实际项目中可能不仅仅是一些数据的增删改查,需要对数据进行计算,但是将计算逻辑放到api层又会拖累整个项目的运行速度,从而会写一些计划任务(使用quartz.net,在上一篇中已经提到)将需要计算的数据提前计算并入库,理论上api层需要做的只是增删改查,从而加快程序运行速度。 传统windows 服务需要创建一个windows service 项目,我自己没有用过,但是看过别人的整个开发流程,感觉及其繁杂并且不容易调试。 使用topshelf可以很快的创建一个服务,而我们需要做的只是创建一个控制台程序,调试成本也大大降低。 步骤如下: 首先还是通过nuget添加topshelf程序集 添加ServiceRunner类,这里用Quartz做例子。当然不仅仅适用于次,也可以用于wcf等。 using Quartz; using Quartz.Impl; using Topshelf; namespace KfqPointService { public sealed class ServiceRunner : ServiceControl, ServiceSuspend { private readonly IScheduler scheduler; public ServiceRunner() {

.netcore组装一个可配置的调用webapi的定期任务服务

余生颓废 提交于 2019-12-03 12:07:13
1.需求 可调用webapi 可通过配置文件配置任务 通过cron进行时间配置 任务执行情况通过日志记录 可封闭成windows服务 有跨平台部署的潜力 2.选型 跨平台 .netcore 定期任务 Quartz.net 调用webapi Restsharp 配置webapi sharpconfig 日志记录 NLog 封闭windows服务 Topshelf 3.类库版本 创建一个控制台程序,我使用的ide是vs2019,通过nuget进行安装以下类库 4.程序结构 5.这是一个基本框架后期可以根据需求扩展,话不多说,上代码。 quartz_jobs.xml 里面配置了一个任务demojob19,每2秒执行一次。 <?xml version="1.0" encoding="utf-8" ?> <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

Quartz写个简单的定时任务

爷,独闯天下 提交于 2019-12-03 10:27:07
spring+maven+Quartz定时任务 1.首先我们在项目中引进Quartz,pom.xml中添加如下包 1 <dependency> 2 <groupId>org.quartz-scheduler</groupId> 3 <artifactId>quartz</artifactId> 4 <version>2.2.1</version> 5 </dependency> View Code 2.在web.xml中有如下配置 1 <!-- Context ConfigLocation --> 2 <context-param> 3 <param-name>contextConfigLocation</param-name> 4 <param-value>classpath*:/spring-context*.xml</param-value> 5 </context-param> View Code 3.添加spring-context-quartz.xml配置文件,专门配置定时任务,1.startQuartz总管理类,启动触发器的配置,2.配置触发器及触发器关联的详细任务。 1 <?xml version="1.0" encoding="UTF-8"?> 2 <beans xmlns="http://www.springframework.org/schema/beans"

Altering Quartz Job Schedule

匿名 (未验证) 提交于 2019-12-03 09:14:57
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm looking into scheduling my application with Quartz, but in all cases, the job trigger seems to be a one-time activity, and changes to the trigger need the application to be re-deployed to take effect. Is there any way I can have the job trigger check for changes to the job schedule without having to redeploy the code? Thanks, 回答1: Trap some user-driven event, like updating a text value, for example a cron-string to schedule a job Locate and unschedule/delete the old job and trigger. Schedule the job again, using the new trigger. public

Quartz Spring CronTrigger fired more times than configured

匿名 (未验证) 提交于 2019-12-03 08:52:47
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a cronTrigger for a job "digestJob": <bean id = "digestCronTrigger" class = "org.springframework.scheduling.quartz.CronTriggerBean" > <property name = "jobDetail" ref = "digestJob" /> <property name = "cronExpression" value = "0 35 15 * * ?" /> </bean> Here is my schedulerFactoryBean configuration: <bean class = "org.springframework.scheduling.quartz.SchedulerFactoryBean" > <property name = "triggers" > <list> <ref bean = "digestCronTrigger" /> </list> </property> </bean> The problem is, the digestCronTrigger is supposed to

What happens to jobs affected by Quartz DisallowConcurrentExecution

匿名 (未验证) 提交于 2019-12-03 08:52:47
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: What happens when a job does not run because of the disallow annotation. Is it queued to run after the currently running instance dies? Is that duplicate "run" of it just thrown away, never to be heard from again? I've tried testing in code, but my inexperience with the language and library is causing some difficulty. 回答1: The additional firings are just delayed (as if no worker thread is available to run them) until the first instance completes. If that causes the next fire time to be missed by more than the scheduler's configured misfire

Mvn clean install tomcat7:deploy fails with “invalid byte tag in constant pool”

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Every time that I run mvn clean install tomcat7:deploy in the command prompt, it fails. When I open the generated log file, it says that there is an invalid byte tag in constant pool. The file that it specifies is java/lang/CharSequence.class. Here is the log: ---- AspectJ Properties --- AspectJ Compiler 1.6.9.RC3 built on Wednesday Jun 30, 2010 at 15:46:30 GMT ---- Dump Properties --- Dump file: ajcore.20141116.131622.157.txt Dump reason: org.aspectj.apache.bcel.classfile.ClassFormatException Dump on exception: true Dump at exit condition: