ABC document, Chinese Document

Source: Internet
Author: User

ABC document, Chinese Document

Document directory

 

Content of this section:

  • Introduction
  • Install
  • Create a job
  • Scheduling
  • More

 

Introduction

Quartz is a fully functional open-source work scheduling system that can be used for minimal application to a large enterprise system. The. Abp. Quartz package can be used to integrate Quartz into the ABP.

If you have a higher scheduling requirement, Quzrtz is a good choice, hangfire is also a good choice for queues for persistent background work.

 

Install

SetAbp. Quartz Install the nuget package in your project andAbpQuartzModuleAddDependsOnFeatures:

[DependsOn(typeof (AbpQuartzModule))]public class YourModule : AbpModule{    //...}

 

Create a job

To create a new job, you must either implement the IJob interface of Quartz or inherit from the JobBase class (defined in. in the Quartz package), JobBase has some helpful attributes and methods (such as logging and localization). A simple Job class is as follows:

public class MyLogJob : JobBase, ITransientDependency{    public override void Execute(IJobExecutionContext context)    {        Logger.Info("Executed MyLogJob :)");    }}

The Execute method is implemented by logging. For more information, see the Quartz document.

 

Scheduling

UseIQuartzScheduleJobManagerTo schedule the work, inject it into your class (or parse its instance in your module's PostInitialize method and then use it) to schedule the work. for example, you can use a controller to schedule a job:

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

For more information about Quartz, see its documentation.

Original ENGLISH

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.