Open-source job scheduling framework-quartz. net

Source: Internet
Author: User

Quartz. net Is an open-source job scheduling framework, which is Opensymphony Of Quartz API Of . Net Port, it uses C # Can be used Winform And Asp.net Application. It provides great flexibility without sacrificing simplicity. You can use it to create simple or complex scheduling for executing a job. It has many features, such as database support, clusters, plug-ins, and support. Cron-like Expressions.


Do you need an application to execute a task? This task is performed every day or every Tuesday evening.11:30, Perhaps only the last day of each month. If a serious error occurs during the execution of an automatic task without intervention, can the application know that the task fails to be executed and try to execute it again? You and your team are using. NetProgramming? If any of these questions is answered, you should useQuartz. netScheduler.Quartz. netAllows developers to schedule jobs by time interval (or day. It realizes the many-to-many relationship between jobs and triggers, and can associate multiple jobs with different triggers. IntegratedQuartz. netApplicationProgramYou can reuse jobs from different events and combine multiple jobs for one event..


Below is the Chinese version of the Official Development Guide Tutorial: English reference official website (http://quartznet.sourceforge.net/tutorial.html)

 

Quartz.netOfficial Development Guide Lesson 1: Use quartz.net

 

UseSchedulerIt should be instantiated before. UseSchedulerfactoryYesSchedulerInstantiation

 

Quartz.netOfficial Development Guide Lesson 2: jobs and triggers

 

Jobdetail ObjectQuartzThe clientJobAddedSchedulerCreate. It containsJobAndJobdatamapObject, which is used to store the givenJobInstance status information.
TriggerThe object is used to triggerJobs. You want to include the task into the progress and instantiateTriggerAnd"Adjustment"Its Attributes meet your desired schedule.TriggersThere is alsoJobdatamapAssociated with the trigger, which is very helpful for the triggerJobPass parameters.QuartzMany different types of packagesTrigger,But the most commonTriggeClass isSimpletriggerAndCrontrigger.

 

Quartz.netOfficial Development Guide Lesson 3:More about jobsAnd jobdetails

 

The implemented classes become real"Job"The expected attributes of the task need to be notifiedQuartz. PassJobdetailClass can complete this job. This class was briefly mentioned in the previous section. Now, let's take some time to discussQuartzMediumJobsNature andJobThe lifecycle of the instance.

 

Quartz.netOfficialDevelopment Guide Lesson 4: triggersMore

 

SameJobSame,TriggerIt is very easy to use, but it has some options that need attention and understanding. At the same time,TriggerThere are different types, you need to select as needed
Quartz.netOfficial Development Guide Lesson 5: simpletrigger

 

If you want a task to be executed only once at a specific time point, or, at a specific time point, and then run the task repeatedly at a specific time interval, simply put, if you want the trigger 2007Year 8Month 20Day Morning11:23:54Second, and then each interval10Repeat once in seconds.5Times. SoSimpletriggerYou can meet your requirements.

 

Quartz.netOfficial Development Guide Lesson 6: crontrigger

 

If you need to trigger a task by calendar like a calendar Simpletrigger That is, it is triggered at a specified interval, Crontriggers Ratio Simpletrigger More useful.
Use Crontrigger You can specify " Every Friday noon " , Or " Every workday 9: 30" Or " From the morning of every Monday, Wednesday, or Friday 9 : 00 To the morning 10 : 00 Every five minutes " In this way, the schedule is triggered. Even, like Simpletrigger Same, Crontrigger There is also Starttime To specify when the calendar starts, there is also an (optional)Endtime To specify when the calendar will not continue.

 

Quartz.netOfficial Development Guide Lesson 7: triggerlistenersAnd joblisteners

 

The listener is inSchedulerObjects that can execute actions when an event occurs. As you can see,TriggerlistenersReceive andTriggersRelated events, andJoblistenersReceive andJobRelated events. 

 

Quartz.netOfficial Development Guide Lesson 8: schedulerlisteners

 

SchedulerlistenersSameTriggerlistenersAndJoblistenersVery similar,SchedulerlistenersOnly receive and specificTriggerOrJobUnrelatedSchedulerEvent Notification.
SchedulerRelated events include: addJobOrTrigger,RemoveJobOrTrigger, SchedulerInternal error,SchedulerNotifications that will be disabled, and other notifications.

 

Quartz.netOfficial Development Guide Lesson 9: jobstore

 

JobstoreMaintains allScheduler"Work data"Tracking, the work data includes:Job(Task), Trigger(Trigger), Calendar (Calendar). For yourQuartz SchedulerSelect an appropriateJobstoreIt is a very important step. Fortunately, if you understand differentJobstoreThen the selection becomes very simple. InSchedulerInstanceSchedulerfactoryAttribute file DeclarationSchedulerTheJobstore(And its configuration)

 

Quartz.netOfficial Development Guide Lesson 10: Configuration, resource usage, and schedulerfactory

 

QuartzIt is structured as a module. Therefore, to run it, several components must be properly integrated. Fortunately, there are already some existing assistants who can complete the work.

 

Quartz.netOfficial Development Guide Lesson 11th: Advanced (enterprise) attributes

 

Clusters can only be usedAdo. Net-jobstore. Server Load balancer and fault toleranceJobdetailOf"Request recovery"MarkTrue) 

 

Quartz.netOfficial Development Guide Lesson 2: quartzOther features

 

Plug-ins Plugin:QuartzProvides an interface(Ischedulerplugin)To insert additional functions.
Jobfactory: When a trigger is triggered, the associated task isSchedulerConfigured inJobfactoryChina. DefaultJobfactorySimply createJobInstance. You may want to create your ownJobfactoryImplementation to completeIOCOrDiContainer generation/InitializationJobFunction of the instance.
'Factory-shipped 'Jobs:QuartzIt also provides some practical functions that can be used in your application.Jobs,For example, send an email or call a remote object. These externalJobYou canQuartz. JobsIn the namespace.

 

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.