Quartz Scheduler - Job State become “Paused” after firing once

Hi,

Jmix version : 1.5.0
Cron set : 0 0/5 * ? * *
There is similar issue raised on below forum, there are other Crons created but they are working fine.
Tried creating new class to work but still it is not working. Any solution to resolve this.

https://forum.jmix.io/t/issue-with-quartz-scheduler-job-state-become-paused-after-or-before-firing-once/5037

Hi,

Did you try 0 0/5 * * * ? instead of 0 0/5 * ? * * ? It’s effectively the same schedule. It’s recommended to use? as day-of-week, not day-of-month - sometimes it doesn’t work for some reason.

Also, does your job really stop working and this is not a bug with displayed status mentioned in linked topic?

  • Do columns Last fire date and Next fire date stop updating?
  • Check table qrtz_triggers - what state has trigger for your job?

And you can add listener to log job start and finish. This may help if something happens within job execution:

@Component
public class JobExecutionMonitoringListener extends JobListenerSupport {

    private static final Logger log = LoggerFactory.getLogger(JobExecutionMonitoringListener.class);

    @Autowired
    private Scheduler scheduler;

    @Override
    public String getName() {
        return "JobExecutionMonitoringListener";
    }

    @PostConstruct
    private void registerListener() {
        try {
            scheduler.getListenerManager().addJobListener(this);
        } catch (SchedulerException e) {
            log.error("Cannot register job listener", e);
        }
    }

    @Override
    public void jobToBeExecuted(JobExecutionContext context) {
        JobKey jobKey = context.getJobDetail().getKey();
        TriggerKey triggerKey = context.getTrigger().getKey();

        log.info("Start job: Job={}, Trigger={}", jobKey, triggerKey);
    }

    @Override
    public void jobWasExecuted(JobExecutionContext context,
                               JobExecutionException jobException) {
        JobKey jobKey = context.getJobDetail().getKey();
        TriggerKey triggerKey = context.getTrigger().getKey();

        if (jobException == null) {
            log.info("Finish job: Job={}, Trigger={}", jobKey, triggerKey);
        } else {
            log.error("Finish job with exception: Job={}, Trigger={}", jobKey, triggerKey, jobException);
        }
    }
}

Regards,
Ivan

1 Like