Here is a basic configuration of my application:
#---------Scheduler Properties----------------
Org.quartz.scheduler.instanceName = Testscheduler
Org.quartz.scheduler.instanceId = One
#---------Thread Configuration---------------
Org.quartz.threadPool.class = Org.quartz.simpl.SimpleThreadPool
Org.quartz.threadPool.threadCount = 2
Org.quartz.threadPool.threadPriority = 4
#---------Job Store Settings------------
Org.quartz.jobStore.class = Org.quartz.simpl.RAMJobStore
#---------Plug-in configuration-------------
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.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
Description of the property
1. Scheduler properties: Set the instance name (instancename) and instance ID (INSTANCEID) of the scheduler, respectively. The Org.quartz.scheduler.instanceName property can be any string you like. The default name is generally Quartzscheduler, the second property org.quartz.scheduler.instanceId and the Instanename property, and the InstanceId property also allows any string. This value must be unique across all scheduler instances, especially in a cluster. If you want Quartz to help you generate this value, you can set it to AUTO.
2. Thread Pool properties: These threads are running in the background in Quartz. The ThreadCount property controls how many worker threads are created to handle the Job. In principle, the more jobs you have to handle, the more worker threads you will need. The value of ThreadCount is at least 1. Quartz does not qualify you to set the maximum worker thread, but it can be quite impractical to set this value above 100 on most machines, especially if your Job executes for a long time. This does not have a default value, so you must set a value for this property.
The ThreadPriority property sets the worker thread's priority. Threads with high priority are executed more preferentially than those with lower levels. The maximum value of the ThreadPriority property is constant Java.lang.Thread.MAX_PRIORITY, which is equal to 10. The minimum value is constant Java.lang.Thread.MIN_PRIORITY, which is 1. The normal value of this property is Thread.norm_priority, which is 5. In most cases, set it to 5, which is also not the default value for the property specified.
The last thread pool property to set is Org.quartz.threadPool.class. This value is a fully-restricted name for a class that implements the Org.quartz.spi.ThreadPool interface. Quartz's own thread pool implementation class is Org.quartz.smpl.SimpleThreadPool, which can meet the needs of most users. This thread pool implementation has a simple behavior and has been well tested. It provides a fixed-size thread pool in the scheduler's life cycle. You can create your own thread pool implementations on demand, and you might need to do this if you want an on-demand, scalable thread pool. This property has no default value and you must specify a value for it.
3. Job Store Properties: The settings in the Job Store section describe how job and Trigger information is stored in the life cycle of the scheduler instance. Storing the scheduler information in memory is very fast and easy to configure. When the scheduler process is terminated, all Job and Trigger status is lost. To enable the job to be stored in memory by setting the Org.quartz.jobStrore.class property to Org.quartz.simpl.RAMJobStore, in cron Trigger and "job store and persist" The different types of job storage implementations that will be used.
4. Other plug-in properties: Org.quartz.plugin.jobInitializer.class = Org.quartz.plugins.xml.JobInitializationPlugin default, the Jobinitializationplugin plugin searches classpath for the name Quartz_jobs.xml File and load the Job and Trigger information from it. Other plugins ...
Quartz_jobs.xml Configuration and explanation
Example: Simple Trigger
- <? XML version= '1.0 ' encoding=' utf-8 '?>
- <quartz>
- <job>
- <job-detail>
- <name> Scandirectory</name>
- <group> DEFAULT</Group>
- <description>
- A job that scans a directory for files
- </Description>
- <job-class>
- Org.cavaness.quartzbook.chapter3.ScanDirectoryJob
- </job-class>
- <volatility>false</volatility>
- <durability>false</durability>
- <recover>false</recover>
- <job-data-map allows-transient-data="true">
- <entry>
- <key> Scan_dir</key>
- <value>c:/quartz-book/input</value>
- </Entry>
- </job-data-map>
- </job-detail>
- <trigger>
- <simple>
- <name>scantrigger</name>
- <group> DEFAULT</Group>
- <job-name> Scandirectory</job-name>
- <job-group> DEFAULT</job-group>
- <start-time>2005-06-10 6:10:00 PM</start-time>
- <!--repeat indefinitely every seconds --
- <repeat-count>-1</repeat-count>
- <repeat-interval>10000</repeat-interval>
- </Simple>
- </trigger>
- </Job>
- </Quartz>
We added the property org.quartz.plugin.jobInitializer.fileName and set the property value to the file name we want. This file name should be visible to ClassLoader, that is, under Classpath.
Third-party Packages
Pass the test. A simple task requires only the following packages: Commons-beanutils.jar, Commons-collections.jar, Commons-logging.jar, Commons-digester.jar, Quartz.jar can
Name |
Must/Remarks |
Url |
Activation.jar |
The main JavaMail to use |
Http://java.sun.com/products/javabeans/glasgow/jaf.html |
Commons-beanutils.jar |
Is |
Http://jakarta.apache.org/commons/beanutils |
Commons-collections.jar |
Is |
Http://jakarta.apache.org/commons/collections |
Commons-dbcp-1.1.jar |
Yes, if the database is used as the job store |
Http://jakarta.apache.org/commons/dbcp |
Commons-digester.jar |
Is |
If you use some plugins, you'll need it. |
Commons-logging.jar |
Is |
http://jakarta.apache.org/commons/logging/ |
Commons-pool-1.1.jar |
|
http://jakarta.apache.org/commons/pool/ |
Javamail.jar |
Send e-mail with |
http://java.sun.com/products/javamail/ |
Jdbc2_0-stdext.jar |
Yes, if the database is used as the job store |
http://java.sun.com/products/jdbc/ |
Jta.jar |
Yes, if the database is used as the job store |
Http://java.sun.com/products/jta/database |
Quartz.jar |
Is |
Quart Framework Core Package |
Servlet.jar |
If the servlet container is used, but the container should exist |
http://java.sun.com/products/servlet/ |
Log4j.jar |
Yes, log |
http://logging.apache.org/ |
Quartz timed Task Learning (iii) properties file and Jar