石英有几个工作,但只有一个运行

时间:2012-07-30 01:20:35

标签: quartz-scheduler

我有几个工作的石英计划,但只有一个(第一个)正在运行。即使我试图强迫第二个工作运行它也不会。

    // The Quartz Scheduler
        Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();


        JobDetailImpl jobDetail = new JobDetailImpl();
        jobDetail.setJobClass(SchedulerJob.class);
        jobDetail.setName("4HR");
        jobDetail.setGroup("G");

        // Initiate CronTrigger with its name and group name
        CronTriggerImpl cronTrigger = new CronTriggerImpl();
        cronTrigger.setName("4HR");
        cronTrigger.setGroup("G");

        // setup CronExpression
        String CRON_EXPRESSION = "0 0 0/4 * * ?"; // fire every 4 hours
        CronExpression cexp = new CronExpression(CRON_EXPRESSION);

        // Assign the CronExpression to CronTrigger
        cronTrigger.setCronExpression(cexp);

        // schedule a job with JobDetail and Trigger
        scheduler.scheduleJob(jobDetail, cronTrigger);



        JobDetailImpl oneHRJob = new JobDetailImpl();
        oneHRJob.setJobClass(Run1HRSchdule.class);
        oneHRJob.setName("Job1HR");
        oneHRJob.setGroup("G");

        CronTriggerImpl oneHRTrigger = new CronTriggerImpl();
        oneHRTrigger.setName("Trigger1HR");
        oneHRTrigger.setGroup("G");


        // Assign the CronExpression to CronTrigger
        String CRON_EXPRESSION_1HR = "0 0 0/1 * * ?"; // fire every 1 hour
        oneHRTrigger.setCronExpression( new CronExpression(CRON_EXPRESSION_1HR) );

        // schedule a job with JobDetail and Trigger
        scheduler.scheduleJob(oneHRJob, oneHRTrigger);

        // start the scheduler
        System.out.println ("Starting Scheduler");

        scheduler.start();

        System.out.println ("Scheduler started:" + scheduler.isStarted() );

        scheduler.triggerJob( oneHRJob.getKey() );

我尝试过更改cron表达式,但没有帮助。

我可能做错了什么?

0 个答案:

没有答案