Use of quartz

Source: Internet
Author: User

Project Structure diagram:

Testmain.java

1  Packagecom;2 ImportOrg.quartz.Scheduler;3 Importorg.quartz.impl.StdSchedulerFactory;4 5  Public classTestmain {6 7      Public Static voidMain (string[] args) {8 9         Try {Ten             //set the classpath of Quartz.properties OneSystem.setproperty ("Org.quartz.properties", "quartz/quartz.properties"); AScheduler Scheduler =Stdschedulerfactory.getdefaultscheduler (); - Scheduler.start (); -}Catch(Exception ex) { the ex.printstacktrace (); -         } -     } -}

Myquartzjob.java

1  Packagetask;2 3 ImportOrg.quartz.Job;4 ImportOrg.quartz.JobExecutionContext;5 Importorg.quartz.JobExecutionException;6 7  Public classMyquartzjobImplementsJob {8     Private Static intnum = 0;9 @OverrideTen      Public voidExecute (jobexecutioncontext arg0)throwsjobexecutionexception { OneSystem.out.println ("Hello world!" + num++); A     } -}

Quartz_jobs.xml

1 <?XML version= ' 1.0 ' encoding= ' utf-8 '?>2 <Quartzxmlns= "Http://www.opensymphony.com/quartz/JobSchedulingData"3 Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"4 xsi:schemalocation= "Http://www.opensymphony.com/quartz/JobSchedulingData5 http://www.opensymphony.com/quartz/xml/job_scheduling_data_1_5.xsd "6 version= "2.0.2">7 8     <!--executes once every 3 seconds -9     <Job>Ten         <Job-detail> One             <name>Myquartzjob</name> A             <Description></Description> -             <Group>Server</Group> -             <Job-class>Task. Myquartzjob</Job-class> the             <Job-data-mapAllows-transient-data= "true" /> -         </Job-detail> -         <Trigger> -             <Cron> +                 <name>Myquartzjobbtriger</name> -                 <Group>Server</Group> +                 <Job-name>Myquartzjob</Job-name> A                 <Job-group>Server</Job-group> at                 <cron-expression>0/3 * * * *?</cron-expression> -             </Cron> -         </Trigger> -     </Job> -      - </Quartz>  

Quartz.properties

#============================================================================ # Configure Main Scheduler Properties  #============================================================================ Org.quartz.scheduler.instanceName = Testscheduler org.quartz.scheduler.instanceId = AUTO #============================================================ ================ # Configure ThreadPool #========================================================================= = = = Org.quartz.threadPool.class = Org.quartz.simpl.SimpleThreadPool #å ¤?ç?? C?? Ǻ¿ç¨?个æ?°org.quartz.threadpool.threadcount = 10#线ç¨?ä¼?å?? Ǻ§å?«  ϼ?ä¸?è?¬ä¸º5 org.quartz.threadPool.threadPriority = 5 org.quartz.threadpool.threadsinheritcontextclassloaderofinitializingthread:true#============================== ============================================== # Configure Jobstore #============================================= =============================== Org.quartz.jobStore.misfireThreshold = 60000 Org.quartz.jobSTore.class = Org.quartz.simpl.RAMJobStore #======================================================================  ====== # Configure Plugins #============================================================================  Org.quartz.plugin.triggHistory.class = Org.quartz.plugins.history.LoggingJobHistoryPlugin  Org.quartz.plugin.jobInitializer.class = org.quartz.plugins.xml.JobInitializationPlugin #FS notice:the classpath of Quartz_jobs.xmlOrg.quartz.plugin.jobInitializer.fileNames =Quartz/quartz_jobs.xml#å ¦?æ?? Jobs.xmlä¸å?å?¨è°?度å?¨ä¸å ²ç»?æ?? C??  Jobï¼?true为è¦?ç?? Org.quartz.plugin.jobInitializer.overWriteExistingJobs = True Org.quartz.plugin.jobInitializer.failOnFileNotFound = True #æ? « Æ?? Jobs.xmlç??  Æ?¶é?´é?´é?? Org.quartz.plugin.jobInitializer.scanInterval = 60000 Org.quartz.plugin.jobInitializer.wrapInUserTransaction = False

  

Use of quartz

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.