`

quartz 进行时间调度(配置式)

阅读更多
   
启动Quartz:
    
    StdSchedulerFactory sf = new StdSchedulerFactory();
    sf.initialize("quartz.properties");
    Scheduler scheduler = sf.getScheduler();
    scheduler.start();


quartz.properties 配置:

# Default Properties file for use by StdSchedulerFactory
# to create a Quartz Scheduler Instance, if a different
# properties file is not explicitly specified.
#
org.quartz.scheduler.instanceName: DefaultQuartzScheduler
org.quartz.scheduler.rmi.export: false
org.quartz.scheduler.rmi.proxy: false
org.quartz.scheduler.wrapJobExecutionInUserTransaction: false

#
org.quartz.threadPool.class: org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount: 25
org.quartz.threadPool.threadPriority: 5
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread: true

#
org.quartz.jobStore.misfireThreshold: 60000
org.quartz.jobStore.class: org.quartz.simpl.RAMJobStore


#
org.quartz.plugin.jobInitializer.class = org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin
org.quartz.plugin.triggHistory.class = org.quartz.plugins.history.LoggingJobHistoryPlugin
org.quartz.plugin.jobInitializer.fileNames = quartz-jobs.xml
org.quartz.plugin.jobInitializer.failOnFileNotFound = true
org.quartz.plugin.jobInitializer.scanInterval = 1000000000
org.quartz.plugin.jobInitializer.wrapInUserTransaction = false



quartz-jobs.xml 文件配置:

<?xml version="1.0" encoding="UTF-8"?>
<job-scheduling-data xmlns="http://www.quartz-scheduler.org/xml/JobSchedulingData"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.quartz-scheduler.org/xml/JobSchedulingData http://www.quartz-scheduler.org/xml/job_scheduling_data_1_8.xsd"
  version="1.8">
    <schedule>

       <job>
           <name>SendEmail(自定义)</name>
           <group>QUARTZ_DEFAULT_JOB_GROUP(自定义)</</group>
           <description>The job description(自定义)</</description>
           <job-class>(你需要执行的class)</class>
       </job>
       <trigger>
           <cron>
                <name>SendEmailTrigger(自定义)</name>
                <group>QUARTZ_DEFAULT_TRIGGER_GROUP(自定义)</</group>
                <job-name>SendEmail(自定义)</job-name>
                <job-group>QUARTZ_DEFAULT_JOB_GROUP(自定义)</job-group>
                <cron-expression>0 0 23 * * ?(调度时间设置)</cron-expression>
           </cron>
       </trigger>
    </schedule>
</job-scheduling-data>


另附几篇博客地址:http://kdisk-sina-com.iteye.com/category/74089
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics