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 ...
随机推荐
- Error:Execution failed for task :app:transformClassesWithInstantRunForDebug解决方案
转自https://blog.csdn.net/student9128/article/details/53026990
- 删除文件夹下各级子目录中的.svn文件
建立一个文本文件,取名为removeSvn.reg(扩展名由txt改为reg),内容如下 Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHIN ...
- docker 学习(九) docker部署静态网站
一: dockerfile, 把Dockerfile和myfolder放在一个目录下: FROM httpd:2.4 COPY ./myfolder/ /usr/local/apache2/htdo ...
- Java笔试面试题整理第八波
转载至:http://blog.csdn.net/shakespeare001/article/details/51388516 作者:山代王(开心阳) 本系列整理Java相关的笔试面试知识点,其他几 ...
- Hive表种map字段的查询取用
建表可以用 map<string,string> 查询时可以按照 aaa[bbb], aaa 是map字段名,bbb是其中的参数名,就可以取到这个参数的值了 当参数名bbb是string时 ...
- ---command line edit and histroy of perl cpan shell
https://www.redhat.com/archives/psyche-list/2003-February/msg00494.html perl -MCPAN -e shell > in ...
- Python介绍与安装
Python 是一种面向对象的解释型程序设计语言,支持支持面向过程.函数式和面向对象编程.另外,Python可以在Windows.UNIX等多个操作系统上使用. 为什么学编程 编程是一种工具,可以实现 ...
- 在delphi中XLSReadWriteII.组件的应用实例(2)
第三方组件:XLSReadWriteII.v.5.20.67_XE3 实例源码如下: unit Unit1; interface uses Winapi.Windows, Winapi.Messa ...
- linux学习资料收藏
http://blog.chinaunix.net/uid/10167808/abstract/1.html?year=2008 http://linux.linuxidc.com/ind ...
- Nginx 工作原理
Nginx 工作原理 Nginx由内核和模块组成. Nginx本身做的工作实际很少,当它接到一个HTTP请求时,它仅仅是通过查找配置文件将此次请求映射到一个location block,而此locat ...