Quartz. NET 2.0 job scheduling framework, quartz. net2.0

Source: Internet
Author: User

Quartz. NET 2.0 job scheduling framework, quartz. net2.0

Quartz. NET is an open-source job scheduling framework and is a. NET port of the Quartz API of OpenSymphony. It is written in C # and can be used in winform and asp.net applications. 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 cron-like expressions.

To schedule a Quartz job, you must: The scheduler (ischedil), the job (JobDetail), and the Trigger (Trigger)

The following code does not require the configuration file:

Using Quartz. impl; using System; namespace Quartz {class Program {static void Main (string [] args) {// The scheduler constructs the factory ISchedulerFactory = new StdSchedulerFactory (); // Step 1: construct the scheduler IScheduler scheduler = factory. getScheduler (); scheduler. start (); // Start the scheduler // Step 2: Define the job JobDetailImpl job = new JobDetailImpl ("MyJob1", typeof (HandleClass); // Step 3: define trigger ITrigger trigger = TriggerBuilder. create (). withIdentity ("t 1 ") // trigger name. forJob (job ). startNow (). withSimpleSchedule (x => x. repeatForever (). withIntervalInSeconds (1) // execute once every 1 s. build (); // Add the task and trigger to the scheduler: scheduler. scheduleJob (job, trigger) ;}/// <summary> /// work class /// </summary> public class HandleClass: IJob {// <summary> /// Method for calling the task /// </summary> public void Execute (IJobExecutionContext context) {Console. writeLine ("hello work! ");}}}

Source Code address: Quartz.zip


There are many java task scheduling frameworks. Which of the following is better to use quartz? Can someone tell me?

It is basically Quartz. I have seen that all projects use Quartz.
Quartz supports Cron expressions to define time points and SimpleTrigger corresponding time points, which can accurately define time points.
Quartz supports clusters and can be automatically allocated to different servers on multiple servers (together with one database) for execution.
Quartz supports multiple error handling methods (such as not executing the error next time, re-executing immediately, and re-executing the error next time)
Quartz supports multiple types of triggering failures (such as shutdown and triggering failures)
Quartz has many advantages. Similar frameworks are basically incomparable with Quartz.

How to get started with Quartz (1)

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, pre-Build of EJB jobs, JavaMail and others, and supports cron-like expressions. Content 1: Quartz makes task scheduling simple 2. Quartz's Development History 3. Getting started with Quartz 4. Quartz internal architecture 5. Job 6. Job Management and storage 7. Effective Job storage 8. Job and trigger 9. Schedule a job 10. Use sched) call your job 11, program Scheduling with declarative scheduling 12, stateful and stateless jobs 13, other features of the Quartz framework 14, Z Next Step 15, learn more about Quartz features you do I need an application to execute a task? This task may only be executed on the last day of each month at every day or Tuesday. 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? Are you and your team using Java programming? If any of these questions is answered, you should use the Quartz scheduler. Note: currently, Matrix Z is widely used in Matrix. For example, the implementation of the ranking statistics function defines a scheduled job through Quartz in Jmatrix. Every morning, the job starts to work and recounts everyone's Karma and ranking. In addition, the generation of RSS files is also defined by Quartz, which generates an rss xml file every 30 minutes. Therefore, Quartz is used in many places. This article is undoubtedly a good entry-level and advanced article. Here, I would like to thank David w Johnson for his efforts! Quartz makes Job Scheduling simple. Quartz is an open-source job scheduling framework fully compiled by Java. Do not use the term job scheduling to scare you. Although the Quartz framework integrates many additional features, you will find it easy to use and unbearable in its simple form !. Create a Java class that implements the org. quartz. Job interface. The Job Interface contains the only method: In your Job interface implementation class, add some logic to the execute () method. Once you configure the Job implementation class and set the scheduling schedule, Quartz will pay close attention to the remaining time. When the scheduler determines that the Job is notified, the Quartz framework will call the execute () method on your Job implementation class (Job class) and allow it to do what it should do. No need to report anything to the scheduler or call anything specific. Simply execute the task and end the task. If you configure your job to be called again later, the Quartz framework will call it again at the right time. If you use other popular open-source frameworks such as struts, you will feel comfortable with the Quartz design and components. Although two open-source projects solve completely different problems, there are many similarities, that is, open-source software users feel comfortable every day.

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.