Quartz timed Task Learning (ii) Web application

Source: Internet
Author: User

Using Quartz in the web

1, first in the Web. xml file to add the following (according to their own circumstances set)

adding Quartzinitializerservlet,quartz in Web. XML to be able to be used in a website application provides a quartzinitializerservlet and a quartzinitializerlistener for loading the web When applied, initializes the quartz.

<servlet>
<servlet-name>
Quartzinitializer
</servlet-name>
<servlet-class>
Org.quartz.ee.servlet.QuartzInitializerServlet
</servlet-class>
<init-param>
<param-name>config-file</param-name>
<param-value>/quartz.properties</param-value>
</init-param>
<init-param>
<param-name>shutdown-on-unload</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

2, the configuration of the Quartz.properties file (each property description of the next write), the contents are as follows:

The above mentioned quartz.properties, which is self-specified, Quartz provides a default configuration file to meet the basic J2SE application, if in the Web application, we want to write the Job,trigger configuration to the file, we need to write, and specify to load our own quratz.properties at initialization, where the position is placed under classes.

Org.quartz.scheduler.instanceName = Testscheduler
Org.quartz.scheduler.instanceId = One

Org.quartz.threadPool.class = Org.quartz.simpl.SimpleThreadPool
Org.quartz.threadPool.threadCount = 2
Org.quartz.threadPool.threadPriority = 4

Org.quartz.plugin.jobInitializer.class = Org.quartz.plugins.xml.JobInitializationPlugin
Org.quartz.plugin.jobInitializer.fileName = Quartz_job.xml
Org.quartz.plugin.jobInitializer.overWriteExistingJobs = False
Org.quartz.plugin.jobInitializer.failOnFileNotFound = True
Org.quartz.plugin.shutdownhook.class = Org.quartz.plugins.management.ShutdownHookPlugin
Org.quartz.plugin.shutdownhook.cleanShutdown = True

3, quartz_job.xml file configuration (each property description of the next write), the contents are as follows:

Quartz to use a plug-in to load its own XML configuration file, which specifies to load the Classes/quartz_job.xml file.

As an example, the simple job simplequartzjob in Quartz timed task learning (a):

<?xml version= "1.0" encoding= "UTF-8"?
<quartz>
<job>
    < Job-detail>
      <name>listener1</name>
       <group>group1</group>
      <job-class>simplequartzjob</ Job-class>

</job-detail>
<trigger>
<cron>
<name>job1</name>
<group>group1</group>
<job-name>listener1</job-name>
<job-group>group1</job-group>
<CRON-EXPRESSION>0/10 * * * *?</cron-expression>
</cron>
</trigger>
</job>

</quartz>

Quartz timed Task Learning (ii) Web application

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.