Quartz调度程序在恢复作业后执行太多

时间:2016-01-30 11:35:20

标签: grails quartz-scheduler

我有一个触发器的工作,实际上我的问题类似于这个Quartz Java resuming a job excecutes it many times

当我试图打开/关闭工作时,这是我的代码。问题是当我试图在暂停很长一段时间后重新安排工作时(在我的情况下是一天),当我重新安排工作时,触发器在同一时间执行太多。我如何在我的代码中使用类PauseAwareCronTrigger? {PauseAwareCronTrigger是来自Quartz Java resuming a job excecutes it many times的类解决方案 }

def rescheduleJob(config) {
        def triggerName = "com.divusi.sipfo."+getJobKeyName(config.namaNotifikasi)
        def triggerName1 = getJobKeyName(config.namaNotifikasi)
        //def triggers = quartzScheduler.getTriggersOfJob(new JobKey("pisReminder", "job"))
        //def trigger = quartzScheduler.getTrigger(triggerKey("pisReminder", "job"))

        def trigger = quartzScheduler.getTrigger(new TriggerKey(getJobKeyName(config.namaNotifikasi), "job"))

        //def trigger = quartzScheduler.getTrigger(new TriggerKey("kpRealizationList", "job"))
        //Trigger trigger = triggers[0];
        /*quartzScheduler.rescheduleJob(trigger.getKey(), TriggerBuilder.newTrigger()
            .withIdentity(triggerName,"job")
            .withSchedule(CronScheduleBuilder.cronSchedule("0 0/1 * * * ?"))
            .build()) */
        if(config.notifikasiAktif) {
         quartzScheduler.rescheduleJob(trigger.getKey(), TriggerBuilder.newTrigger()
            .withIdentity(getJobKeyName(config.namaNotifikasi),"job")
            .withSchedule(CronScheduleBuilder.cronSchedule("0/1 * * * * ?"))
            .build())
        }else{
            quartzScheduler.pauseTrigger(trigger.getKey())
        }



        /*trigger.cronExpression = "0/1 * * * * ?" config.cronExpression
        quartzScheduler.rescheduleJob(new TriggerKey("pisReminder", "job"), trigger) */
    } 

0 个答案:

没有答案