Quartz Scheduler Learning (2)

Source: Internet
Author: User

http://quartz-scheduler.org/documentation/quartz-2.x/cookbook/defines many examples of how to use quartz

1, Initialize Scheduler

Initialize the scheduler, one is to create a stdschedulerfactory first, and then from Stdschedulerfactory.getscheduler (), the scheduler obtained here is the default configuration. The other is to initialize the scheduler from the configuration file.

New= Sf.getscheduler ();

2,scheduler can be in standby mode, or "standby" mode, scheduler in this mode cannot trigger job execution conditions and cannot execute jobs.

Scheduler.standby (); // To put the scheduler into "standby" mode

Recover from "standby" mode, execute: Scheduler.start ();

3, Close Scheduler

Call the Shutdown () method to close scheduler, and once the shutdown method is called, the scheduler can no longer restart because its resources and related threads have been recycled.

When you close the scheduler, you face two situations. One is to close the scheduler while waiting for job execution to complete, and the other is to close the scheduler immediately. The parameters received by the shutdown method are used to determine which case.

Scheduler.shutdown (true); // wait for job execution to complete before shutting down the scheduler
Scheduler.shutdown (); // Shutdown Scheduler directly // orScheduler.shutdown (false); // Shutdown Scheduler directly

4,quartz can be integrated with the Web. When scheduler can be initialized in a servlet container, the appropriate configuration is required in the Web. xml file. Reference: Servletinitscheduler

5, use multiple scheduler in non-clustered mode (multiple work thread can be configured under each scheduler (configured in quartz.properties file))

For quartz, each scheduler must have a unique name, that is, different scheduler names must be different. The Quartz.properties file specifies the scheduler name for the scheduler. This means that more than one quartz.properties file is required, and each file is given a corresponding property configuration for a scheduler.

6, save the job for later use.

// ADD The job to the scheduler ' s store false);

7, how to update a job that already exists

8, how to update the trigger

9, List all jobs dispatched by the scheduler

10 .... Some very common small examples of using quartz .....

Quartz Scheduler Learning (2)

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.