Reputation: 95
I try to check the Quartz Scheduler status with the code below, but the status return is confusing. Why after I shutdown the scheduler the isStarted status still true and after I re-start the scheduler the isShutDown status is true.
if (logger.isLoggable(Level.INFO)) {
logger.info("Before: Stand by: "
+ this.scheduler.isInStandbyMode() + ", Start: "
+ this.scheduler.isStarted() + ", Shutdown: "
+ this.scheduler.isShutdown());
}
this.scheduler.start();
if (logger.isLoggable(Level.INFO)) {
logger.info("After: Stand by: "
+ this.scheduler.isInStandbyMode() + ", Start: "
+ this.scheduler.isStarted() + ", Shutdown: "
+ this.scheduler.isShutdown());
}
//Shutdown scheduler
this.scheduler.shutdown(true);
if (logger.isLoggable(Level.INFO)) {
logger.info("Schedule stop: Stand by: "
+ this.scheduler.isInStandbyMode() + ", Start: "
+ this.scheduler.isStarted() + ", Shutdown: "
+ this.scheduler.isShutdown());
}
//Restart scheduler
this.scheduler.start();
if (logger.isLoggable(Level.INFO)) {
logger.info("schedule start: Stand by: "
+ this.scheduler.isInStandbyMode() + ", Start: "
+ this.scheduler.isStarted() + ", Shutdown: "
+ this.scheduler.isShutdown());
}
And the result return is
Upvotes: 1
Views: 1346
Reputation:
While this may seem like a bug, it is in fact by design. The isStarted() and isShutdown() methods do not report the current status of the Quartz Scheduler, instead they are to only be used to determine if at some point in the past the Scheduler has been started or shutdown. Please see the following Javadoc:
/**
* Whether the scheduler has been started.
*
* <p>
* Note: This only reflects whether <code>{@link #start()}</code> has ever
* been called on this Scheduler, so it will return <code>true</code> even
* if the <code>Scheduler</code> is currently in standby mode or has been
* since shutdown.
* </p>
*
* @see #start()
* @see #isShutdown()
* @see #isInStandbyMode()
*/
boolean isStarted() throws SchedulerException;
Upvotes: 1