1

i have a job with one trigger, actually my problem is similar to this Quartz Java resuming a job excecutes it many times

Here is my code when i was trying to turn on/off job. The problem is when i was trying to reschedule job after paused for long time(in my case is one day), the trigger executes too many in the same time when i reschedule the job. And how i use class PauseAwareCronTrigger in my code ? {PauseAwareCronTrigger is class solution from 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) */
    } 
Community
  • 1
  • 1
  • i have problems with the solution by create new wrapper class PauseAwareCronTrigger in my code, after i create the class what i do for my code ? just call this statement trigger.setMisfireInstruction(PauseAwareCronTrigger.MISFIRE_INSTRUCTION_DO_NOTHING); will affect my trigger ? – Jais Anasrulloh Ja'fari Jan 30 '16 at 11:39
  • What do you mean by "the trigger executes many task"? Does it run the same job? – Armaiti Jan 30 '16 at 15:17
  • My bad, i mean too much executions in the same time after i resumed. I had paused job for 4 hours then i resumed it, after resumed job executed too much at the same time i resumed. It looks like after resumed,the nextfiretrigger remains old so at the first time i resumed job executes misfire as many as do when it paused for 4 hours. – Jais Anasrulloh Ja'fari Jan 30 '16 at 16:29
  • i have edited it, hope you can give me solution soon – Jais Anasrulloh Ja'fari Jan 30 '16 at 16:38
  • Remember that when you pause the job for a long time, meaning that it has passed scheduled execution time, Quartz will execute the job first, when you start the job. Quartz thinks that the job that supposed to be executed didn't executed as scheduled and it will execute it. – Armaiti Jan 30 '16 at 16:42
  • i looks like after i paused the trigger, trigger will continue to fire but the executions will queue up until the job is resumed, i just want the trigger executes after i resumed not start from queue executions – Jais Anasrulloh Ja'fari Jan 30 '16 at 16:46
  • Yes, that's what it does. One remedy would be to stop the job and reschedule it. – Armaiti Jan 30 '16 at 16:47
  • okay, have you any idea to resume trigger without fire task in queue but start from when i resumed ? i have so depressed with this module – Jais Anasrulloh Ja'fari Jan 30 '16 at 16:49
  • To be safe, before you pause the job reschedule it in the future date, long enough that doesn't pass the scheduled time. . – Armaiti Jan 30 '16 at 16:58
  • you mean by changing the cronexpression ? – Jais Anasrulloh Ja'fari Jan 30 '16 at 17:00
  • yes, that way it doesn't execute it when the job is un-paused. – Armaiti Jan 30 '16 at 17:04
  • okay in my cronexpression i have "0/1 * * * * ?", what if i just paused it not to change the cronexpression ? – Jais Anasrulloh Ja'fari Jan 30 '16 at 17:09
  • or there is no hope to resume without fire any executions in the queue ? – Jais Anasrulloh Ja'fari Jan 30 '16 at 17:10
  • or there is no hope using quartz scheduler to schedule executions or task – Jais Anasrulloh Ja'fari Jan 30 '16 at 17:10

0 Answers0