Quartz (i) scheduler originally configured

Source: Internet
Author: User
Tags log4j

Brief Introduction:

Quartz provides job scheduling service, can be used in Java programs, try this here.


Reference (Http://www.quartz-scheduler.org/documentation/quartz-2.2.x/quick-start)


steps:

1. Download

Http://www.quartz-scheduler.org/downloads/catalog


2. After the decompression, the Lib folder under the content, put the project under the class path



There are these libraries, all added to the path.




2. Establish the Quartz profile quartz.properties

Org.quartz.scheduler.instanceName = Myscheduler
org.quartz.threadPool.threadCount = 3
Org.quartz.jobStore.class = Org.quartz.simpl.RAMJobStore

Add Log4j.xml

<?xml version= "1.0" encoding= "UTF-8"?> <!
DOCTYPE log4j:configuration SYSTEM "Log4j.dtd" >

<log4j:configuration xmlns:log4j= "http://" jakarta.apache.org/log4j/">

  <appender name=" Default "class=" Org.apache.log4j.ConsoleAppender ">
    <param name= "target" value= "System.out"/> <layout class=
    "Org.apache.log4j.PatternLayout" >
      <param name= "Conversionpattern" value= "[%p]%d{dd MMM. SSS AA}%t [%c]%n%m%n%n "/>
    </layout>
  </appender>


 <logger name=" Org.quartz ">
   <level value= "info"/>
 </logger>

  <root>
    <level value= "info"/>
    < Appender-ref ref= "Default"/>
  </root>

  
</log4j:configuration>



Code:

Package COM.ANIALY.TQ;

Import Org.quartz.Scheduler;
Import org.quartz.SchedulerException;
Import org.quartz.impl.StdSchedulerFactory;

public class Testquartz {
    
	private static Scheduler Scheduler;
    public static void Main (string[] args) {

        try {
        	//Grab The Scheduler instance from the Factory 
        	= STD Schedulerfactory.getdefaultscheduler ();

            and start it off
            Scheduler.start ();

            Scheduler.shutdown ();

        } catch (Schedulerexception se) {
            se.printstacktrace ();}}}


Output:


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.