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 ...
随机推荐
- Pascal语言(存档)
数据类型 标准函数 运算符和表达式 输入语句 输出语句 if语句 case语句 for语句 while语句 repeat语句 函数与过程 形参与实参 全局变量与局部变量 数组 字符串 枚举 子界 集合 ...
- Oracle 学习笔记(五)
--表空间,auto: 自动管理, manual: 手动管理 create tablespace tsp1 datafile 'D:\ORACLE\ORADATA\O10\tsp1.dbf' ...
- Servlet工作原理解析
Web 技术成为当今主流的互联网 Web 应用技术之一,而 Servlet 是 Java Web 技术的核心基础.要介绍 Servlet 必须要先把 Servlet 容器说清楚,Servlet 与 S ...
- Spring -- <tx:annotation-driven>注解基于JDK动态代理和CGLIB动态代理的实现Spring注解管理事务(@Trasactional)的区别。
借鉴:http://jinnianshilongnian.iteye.com/blog/1508018 基于JDK动态代理和CGLIB动态代理的实现Spring注解管理事务(@Trasactional ...
- Myeclipse版本引发的css样式问题:头部自动生成一行代码导致样式引入不成功
在运行新的项目之后,发现样式全部没了 利用开发者模式查看原因:是因为css样式文件的顶部自动生成了一行代码导致的 生成的代码:[genuitec-file-id="wc2-7"], ...
- 深入理解Java虚拟机之Java内存区域随笔
1.java内存区域与内存溢出异常 Java 虚拟机在执行 Java 程序的过程中会把它管理的内存划分成若干个不同的数据区域:1.程序计数器,2.栈(虚拟机栈和本地方法栈 ),3.堆,4.方法区(包含 ...
- install mysql from source and troubleshooting example
I tried to install MySQL 5.7 from source file and upgrading previous MySQL version to the lastest 5. ...
- 深入浅出PF 学习笔记---TypeConverter
StringToHumanTypeConverter类(从TypeConverter继承 using System; using System.Collections.Generic; using S ...
- Windows Server 2012安装密钥
Windows Server 2012 Standard 密钥:NB4WH-BBBYV-3MPPC-9RCMV-46XCB Windows Server 2012 StandardCore 密钥:NB ...
- Linux基本的操作
一.为什么我们要学习Linux 相信大部分人的PC端都是用Windows系统的,那我们为什么要学习Linux这个操作系统呢???Windows图形化界面做得这么好,日常基本使用的话,学习成本几乎为零. ...