ABP框架系列之四十五:(Quartz-Integration-Quartz-集成)
Introduction
Quartz is a is a full-featured, open source job scheduling system that can be used from smallest apps to large scale enterprise systems. Abp.Quartz package simply integrates Quartz to ASP.NET Boilerplate.
Quartz是一个功能齐全的开源作业调度系统,可以从最小的应用程序到大型企业系统使用。Abp.Quartz包简单地集成ASP.NET样板。
ASP.NET Boilerplate has a built-in persistent background job queue and background worker system. Quartz can be a good alternative if you have advanced scheduling requirements for your background workers. Also,Hangfire can be a good alternative for persistent background job queue.
ASP.NET的模板有一个内置的持久后台作业队列和背景工人系统。如果你对你的背景工作者有高级的进度要求,Quartz是一个不错的选择。另外,迟发性可以持续背景任务队列的一个很好的选择。
Installation
Install Abp.Quartznuget package to your project and add a DependsOn attribute to your module for AbpQuartzModule:
[DependsOn(typeof (AbpQuartzModule))]
public class YourModule : AbpModule
{
//...
}
Creating Jobs
To create a new job, you can either implement Quartz's IJob interface, or derive from JobBase class (defined in Abp.Quartz package) that has some helper properties/methods (for logging and localization for example). A simple job class is shown below:
创建一个新的工作,你可以实现 Quartz的ijob接口,或者从jobbase类(ABP。石英包中定义的),有一些辅助属性/方法(记录和定位为例)。下面显示一个简单的作业类:
public class MyLogJob : JobBase, ITransientDependency
{
public override void Execute(IJobExecutionContext context)
{
Logger.Info("Executed MyLogJob :)");
}
}
We simply implemented the Execute method to write a log. You can see Quartz's documentation for more.
Schedule Jobs(安排工作)
IQuartzScheduleJobManager is used to schedule jobs. You can inject it to your class (or you can Resolve and use it in your module's PostInitialize method) to schedule jobs. An example Controller that schedules a job:
iquartzschedulejobmanager来安排工作。你可以将它注入到你的类(或你可以解决和使用你的模块的postinitialize法)安排工作。调度工作的示例控制器:
public class HomeController : AbpController
{
private readonly IQuartzScheduleJobManager _jobManager; public HomeController(IQuartzScheduleJobManager jobManager)
{
_jobManager = jobManager;
} public async Task<ActionResult> ScheduleJob()
{
await _jobManager.ScheduleAsync<MyLogJob>(
job =>
{
job.WithIdentity("MyLogJobIdentity", "MyGroup")
.WithDescription("A job to simply write logs.");
},
trigger =>
{
trigger.StartNow()
.WithSimpleSchedule(schedule =>
{
schedule.RepeatForever()
.WithIntervalInSeconds(5)
.Build();
});
}); return Content("OK, scheduled!");
}
}
More
Please see Quartz's documentation for more information about Quartz.
ABP框架系列之四十五:(Quartz-Integration-Quartz-集成)的更多相关文章
- ABP框架系列之四十九:(Startup-Configuration-启动配置)
		
ASP.NET Boilerplate provides an infrastructure and a model to configure it and modules on startup. A ...
 - ABP框架系列之十五:(Caching-缓存)
		
Introduction ASP.NET Boilerplate provides an abstraction for caching. It internally uses this cache ...
 - ABP框架系列之四十二:(Object-To-Object-Mapping-对象映射)
		
Introduction It's a common to map a similar object to another object. It's also tedious and repeatin ...
 - ABP框架系列之四十:(Notification-System-通知系统)
		
Introduction Notifications are used to inform users on specific events in the system. ASP.NET Boiler ...
 - ABP框架系列之四十四:(OWIN)
		
If you are using both of ASP.NET MVC and ASP.NET Web API in your application, you need to add Abp.Ow ...
 - ABP框架系列之四十六:(Setting-Management-设置管理)
		
Introduction Every application need to store some settings and use these settings in somewhere in th ...
 - ABP框架系列之四十八:(Specifications-规范)
		
Introduction Specification pattern is a particular software design pattern, whereby business rules c ...
 - ABP框架系列之三十五:(MVC-Controllers-MVC控制器)
		
Introduction ASP.NET Boilerplate is integrated to ASP.NET MVC Controllers via Abp.Web.Mvc nuget pack ...
 - ABP框架系列之五十四:(XSRF-CSRF-Protection-跨站请求伪造保护)
		
Introduction "Cross-Site Request Forgery (CSRF) is a type of attack that occurs when a maliciou ...
 
随机推荐
- 推导式_字典_enumerate
			
字典推导式_enumerate: ''' 功能: 枚举, 拿出iter的每一个元素和索引(可以设置start改变) 组队放入一个元祖中返回 参数:iterable, start(指定索引开始的位置) ...
 - Window10下安装sbt
			
参考:https://segmentfault.com/a/1190000002474507 下载:https://dl.bintray.com/sbt/native-packages/sbt/0.1 ...
 - Java笔记Spring(四)
			
spring web项目启动入口 1.首先看一下传统Java Web的配置文件web.xml,网上找的一个,参考地址:https://blog.csdn.net/github_36301064/art ...
 - Java笔试面试题整理第五波
			
转载至:http://blog.csdn.net/shakespeare001/article/details/51321498 作者:山代王(开心阳) 本系列整理Java相关的笔试面试知识点,其他几 ...
 - 6-安装hbase
			
1.前提条件 ①安装zookeeper ②安装hdfs ③由于Hbase对时间的要求比较苛刻,所以3台节点时间必须同步,否则会报错 s10 zookeeper RegionServer HMaster ...
 - Python(算法)-时间复杂度和空间复杂度
			
时间复杂度 算法的时间复杂度是一个函数,它定量描述了该算法的运行时间,时间复杂度常用“O”表述,使用这种方式时,时间复杂度可被称为是渐近的,它考察当输入值大小趋近无穷时的情况 时间复杂度是用来估计算法 ...
 - syslog-ng日志收集分析服务搭建及配置
			
syslog-ng日志收集分析服务搭建及配置:1.网上下载eventlog_0.2.12.tar.gz.libol-0.3.18.tar.gz.syslog-ng_3.3.5.tar.gz三个软件: ...
 - 转载:c++深拷贝和浅拷贝
			
文章来自:http://blog.csdn.net/u010700335/article/details/39830425 C++中类的拷贝有两种:深拷贝,浅拷贝:当出现类的等号赋值时,即会调用拷贝函 ...
 - 使用AsyncTask类实现简单的异步处理操作
			
AsyncTask: 1.这是一种相比Handler更轻量级的处理异步任务的工具类 2.它和Handler类一样,都是为了不影响主线程(UI)而使用的((注:UI的更新只能在主线程中完成) 3.这个工 ...
 - 群晖上使用kvm(qemu)笔记[原创]
			
1.今日偶然逛github里发现一个项目:https://github.com/bsdcpp/synoKVM 下载spk后手工安装,马上可以使用 2.新建XP实例后发现xp的安装盘不认识qemu的vi ...