Quartz 配置实例
jobInitial.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE quartz PUBLIC
"-//Quartz Enterprise Job Scheduler//DTD Job Scheduling Data 1.0//EN"
"http://www.quartzscheduler.org/dtd/job_scheduling_data_1_0.dtd">
<quartz>
<job>
<job-detail>
<name>Job1</name>
<group>DEFAULT</group>
<job-class>MyPackage.TestJob</job-class>
</job-detail>
<trigger>
<cron>
<name>trigger1</name>
<group>DEFAULT</group>
<job-name>Job1</job-name>
<job-group>DEFAULT</job-group>
<cron-expression>0 0/1 * * * ?</cron-expression>
<!-- every 1 minutes... -->
</cron>
</trigger>
</job>
<job>
<job-detail>
<name>Job2</name>
<group>DEFAULT2</group>
<job-class>MyPackage.Job2</job-class>
</job-detail>
<trigger>
<cron>
<name>trigger2</name>
<group>DEFAULT2</group>
<job-name>Job2</job-name>
<job-group>DEFAULT2</job-group>
<cron-expression>0 0/2 * * * ?</cron-expression>
<!-- every 1 minutes... -->
</cron>
</trigger>
</job>
</quartz>
Quart.properties
# ===========================================================================
# Configure Main Scheduler Properties ======================================
# ===========================================================================
org.quartz.scheduler.instanceName = sched1
org.quartz.scheduler.instanceId = 1
# ===========================================================================
# Configure ThreadPool =====================================================
# ===========================================================================
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 3
org.quartz.threadPool.threadPriority = 5
# ===========================================================================
# Configure JobStore =======================================================
# ===========================================================================
org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore
org.quartz.jobStore.misfireThreshold = 60000
# ===========================================================================
# Configure SchedulerPlugins ===============================================
# ===========================================================================
org.quartz.plugin.triggHistory.class = org.quartz.plugins.history.LoggingTriggerHistoryPlugin
org.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.JobInitializationPlugin
org.quartz.plugin.jobInitializer.fileName = jobInitial.xml
org.quartz.plugin.jobInitializer.overWriteExistingJobs = true
org.quartz.plugin.jobInitializer.failOnFileNotFound = true
org.quartz.plugin.jobInitializer.validating = false
org.quartz.plugin.jobInitializer.validatingSchema = true
MAIN类
public class MainClass {
static Logger logger = Logger.getLogger(MainClass.class.getName());
public static void main(String args[]) {
SchedulerFactory schedFact = new org.quartz.impl.StdSchedulerFactory();
Scheduler sched = null;
try {
sched = schedFact.getScheduler();
sched.start();
logger.debug(">>>>> Initial Schedule Start >>>>>>>>>");
} catch (SchedulerException e) {
logger.debug(">>>>> Initial Schedule Start Failed!!!", e);
try {
sched.shutdown();
} catch (SchedulerException e1) {
logger.debug(">>>>> Initial Schedule Shutdown Failed!!!", e);
e1.printStackTrace();
}
e.printStackTrace(System.err);
}
}
}
JOB 类
public class TestJob implements Job {
public void execute(JobExecutionContext arg0) throws JobExecutionException {
// TODO Auto-generated method stub
System.out.println(" TestJob Start arg0=" + arg0);
System.out.println(" -----------------test-----------------------");
}
}
posted on 2006-03-01 22:32
square 阅读(1655)
评论(4) 编辑 收藏