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:Could not determine the class-path for interface com.android.builder.model.AndroidProject.
见https://blog.csdn.net/qq_21397217/article/details/65630730博客
- 20165312 2017-2018-2《Java程序设计》课程总结
20165312 2017-2018-2<Java程序设计>课程总结 每周作业链接汇总 预备作业1:我期望的师生关系 预备作业2:C语言基础调查和java学习展望 预备作业3:Linux安 ...
- 配置gitlab自动备份
在gitlab机器的root用户执行 首先,假设有2台机器. gitlab 1.1.1.1 backup 2.2.2.2 做秘钥信任 gitlab root 生成 ssh-key copy密钥到bac ...
- 搭建sparksql的hive测试环境
sbt依赖 name := "Pi" version := "1.0" scalaVersion := "2.10.6" libraryDe ...
- 5-安装sqoop
1.解压,修改权限 sudo tar -zvxf sqoop-1.4.6.bin__hadoop-2.0.4-alpha.tar.gz -C /opt/app/ sudo chown -R hadoo ...
- Python入门教程丨1300多行代码,让你轻松掌握基础知识点
欢迎关注小编,除了分享技术文章之外还有很多福利,私信学习资料可以领取包括不限于Python实战演练.PDF电子文档.面试集锦.学习资料等. 前言 本文适合有经验的程序员尽快进入Python世界.特别地 ...
- win7+win10系统使用日常经验集锦
请保留此份 Cmd Markdown 的欢迎稿兼使用说明, 当然你也可以使用彩色字体. 或者使用小体字. 或者使用大体字. 如需撰写新稿件,点击顶部工具栏右侧的 新文稿 或者使用快捷键 Ctrl+Al ...
- leetcode每日刷题计划-简单篇day3
收到swe提前批面试hhh算是ep挂了的后续 努力刷题呀争取今年冲进去! Num 21 合并两个有序链表 Merge Two Sorted Lists 注意新开的链表用来输出结果的是ListNode ...
- 开源项目初涉(C++自我学习开始)
版权声明:本文为博主原创文章,未经博主允许不得转载. https://i.cnblogs.com/EditPosts.aspx?postid=8428885 临近2018农历新年,我还在上班,哈哈. ...
- Hive 任务优化 tips
1. 集群任务队列: 一般有 root.default, root.online, root.offline, root.spark-thiftserver Hue提交的任务一般默认在 defau ...