Skip to content

Commit

Permalink
0003222: When restarting a cron job print out the next scheduled time
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Aug 10, 2017
1 parent 3867f73 commit f13ee8b
Showing 1 changed file with 5 additions and 2 deletions.
Expand Up @@ -37,8 +37,10 @@
import org.springframework.jmx.export.annotation.ManagedMetric;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.scheduling.TriggerContext;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.scheduling.support.SimpleTriggerContext;

@ManagedResource(description = "The management interface for a job")
abstract public class AbstractJob implements Runnable, IJob {
Expand Down Expand Up @@ -93,8 +95,9 @@ public void start() {
int timeBetweenRunsInMs = engine.getParameterService().getInt(
jobName + ".period.time.ms", -1);
if (!StringUtils.isBlank(cronExpression)) {
log.info("Starting {} with cron expression: {}", jobName, cronExpression);
this.scheduledJob = taskScheduler.schedule(this, new CronTrigger(cronExpression));
CronTrigger cron = new CronTrigger(cronExpression);
log.info("Starting {} with cron expression: {}. Next scheduled time is: {}", jobName, cronExpression, cron.nextExecutionTime(new SimpleTriggerContext()));
this.scheduledJob = taskScheduler.schedule(this, cron);
started = true;
} else {
int startDelay = randomTimeSlot.getRandomValueSeededByExternalId();
Expand Down

0 comments on commit f13ee8b

Please sign in to comment.