Quartz Getting Started - Realizing Schedule with XML.

xiaoxiao2021-03-06  50

Getting Started with XML - Using XML. The schedule .author: meanson wangemail: meansonw@hotmail.comdate: 2004-12-12section 01: Why quartzquartz is an enterprise-class schedule [Schedule] software, there are familiar cron definitions under UNIX, Simple definition method. Quartz's storage mode can be a memory storage or a database can be used to achieve persistence. Section 02: Why this article This article is found in the process of starting with Quartz, watching Quartz's document is a painful thing, because you want to cross the staddy in the afternoon, it finds that it even has no Quick Start, except depressed Don't have no way. This article is a practical style, directly introduces how you can use Quartz, at least, replace Timer.SECTION 03: How to start ... This article describes how to start Quartz tasks with XML. 1. Download Quartz to put Quartz inside yourappl / Web-Inf / Lib. 2. Configure web.xml to start the Quartz service. Add the following in Yourrappl / Web-INF / Web.xml. QuartzInitializer Quartz Initializer Servlet org.quartz.ee.servlet.QuartzInitializerServlet < Load-on-startup> 1 3. Configure your task file quartz_reminder.xml, create Job and TRIGGER. In yourappl / web-inf / web.xml, create a new file quartz_reminder. XML The following example establishes two schedule, one to execute the Scheduling.quartzemail task every 15 minutes, one is the week 1-5 8:30 AM execute the Scheduling.quartzdailyReminder task. You can build quartzemail.class, quartzdailyReminder.class is placed in Yourappl / Web-INF / CLASSES / Scheduling. Note that a schedule is made up of a Job and a TRIGGER, representing task definitions, and time definitions.

job_email default scheduling.quartzemail Trigger_Email default job_email default 0 0/15 * * *? job_daily_reminder < Group> Default scheduling.quartzdailyreminder Trigger_daily_reminder default < Job-name> job_daily_reminder default 0 30 8? * Mon-f Ri 4. Configure Quartz.Properties to create a new file quartz.properties in Yourappl / Web-Inf / Web.xml # Configure Main Scheduler Properties # org.quartz.scheduler.instanceName = testschedulerorg.quartz.scheduler.instanceId = One

## Configure threadpool #

Org.quartz.threadpool.class = org.quartz.simpla.SIMPLETHREADPOOLORG.QUARTZ.THREADPOOL.THREADPOOL.THREADPRIRITY = 4 ## Configure jobstore #

Org.quartz.jobstore.MisfirethReshold = 5000

Org.quartz.jobstore.class = org.quartz.simpl.ramjobstore

# ===================================================== ========================== # configure schedulerplugins ===================== ========================== # ==================================================================================================================================================================================== ============================================================================================================================================================================================================= .. == org.quartz.plugin.triggHistory.class = org.quartz.plugins.history.LoggingTriggerHistoryPluginorg.quartz.plugin.triggHistory.triggerFiredMessage = Trigger {1} {0} fired job {6} {5} at: { 4, date, hh: mm: ss mm / dd / yyyy} org.quartz.plugin.trigghistory.triggercompleteMessage = trigger {1}. {0} completed firing job {6}. {5} at {4, Date, HH : mm: ss mm / dd / yyyy} with resulting trigger instruction code: {9}

org.quartz.plugin.jobInitializer.class = org.quartz.plugins.xml.JobInitializationPluginorg.quartz.plugin.jobInitializer.fileName = /quartz_reminder.xmlorg.quartz.plugin.jobInitializer.overWriteExistingJobs = falseorg.quartz.plugin.jobInitializer.failOnFileNotFound = Trueorg.quartz.plugin.shutdownhook.class = org.quartz.plugins.Management.shutdownhookPluginorg.quartz.plugin.shutdownhook.cleanshutdown = true

Ok, now you will find a JSP server, pay attention to the output of logs, you can test your schedule. Postscript: 2004-12-20quartz uses the following file header: It analyzes the XML file with the DTD file. This is not a problem, the problem is, this DTD file is placed on the Quartz website, if your server can't access the Internet, your quartz can't work properly. Solution: 1. Copy the DTD folder of the DOCS in Quartz1.4.2.zip to your application yourappl. 2. Modify the file header of the XML file: 3. Enter the absolute path is also possible, such as" / Tomcat/yourappl/dtd/job_scheduling_data_1_0.dtd "

Attached: CRONEXPRESSION configuration instructions

Special characters allowed by field allow for special characters to be allowed by 0-59, - * / 分 0-59, - * / hour 0-23, - * / Date 1-31, - *? / LWC month 1-12 or Jan-Dec, - * / Week 1-7 or Sun-sat, - *? / Lc # years (optional) Leaves the blank, 1970-2099, - * /

转载请注明原文地址:https://www.9cbs.com/read-81613.html

New Post(0)