I'm using the currently latest quartz 1.8.3 on jboss 4.0.5. The quartz jobs are persistent and saved into a local database. When I call the shutdown or standby method on the executing quartz scheduler object jobs still continue to execute by the scheduler, only that the jobs state is empty and the execution fails.
I would expect (at least according to quartz API documentation) that when I shutdown or make the scheduler standby, that jobs previously scheduled into the database will not be executed.
If calling shutdown or standby on the scheduler is not the method to achieve that, what is?
The jobs are not just finishing the execution but planned jobs continue to be triggered.
Here is additional info as asked:
public class QuartzNotificationsSchedulerBean implements NotificationsScheduler, ServletContextAware {
...
public String scheduleNotification(Notification notification) {
// Schedule the job with the trigger
try {
// Define job instance
String groupName = this.createNotificationGroupName(notification);
String triggerName = this.createNoficationTriggerName(notification);
String jobName = this.createNoficationJobName(notification);
JobDetail job = new JobDetail(jobName, groupName , ScheduledNotificationJob.class);
JobDataMap jobDataMap = new JobDataMap();
jobDataMap.putAll(notification.getContext());
job.setJobDataMap(jobDataMap);
Calendar notificationTime = notification.getTime();
Trigger trigger = new SimpleTrigger(triggerName, groupName , notificationTime.getTime());
scheduler.scheduleJob(job, trigger);
return trigger.getName();
} catch (SchedulerException e) {
throw new NotificationScheduleException(e, notification);
}
return null;
}
public void setServletContext(ServletContext servletContext) {
this.sf = (SchedulerFactory) servletContext.getAttribute(QuartzInitializerListener.QUARTZ_FACTORY_KEY);
try {
scheduler = sf.getScheduler();
if(scheduler.isStarted() == false) {
scheduler.start();
}
} catch (SchedulerException e) {
logger.error("Failed to load Quartz scheduler ", e);
}
}
}
The following is a copy of the quartz configuration properties:
#============================================================================
# Configure Main Scheduler Properties
#============================================================================
org.quartz.scheduler.instanceName = scheduler
org.quartz.scheduler.instanceId = AUTO
org.quartz.scheduler.wrapJobExecutionInUserTransaction = true
#============================================================================
# Configure ThreadPool
#============================================================================
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 45
org.quartz.threadPool.threadPriority = 5
#============================================================================
# Configure JobStore
#============================================================================
org.quartz.jobStore.misfireThreshold = 60000
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
#org.quartz.jobStore.useProperties = false
org.quartz.jobStore.dataSource = FOR_QUARTZ
org.quartz.jobStore.isClustered = true
org.quartz.jobStore.clusterCheckinInterval = 20000
#============================================================================
# Configure Datasources
#============================================================================
org.quartz.dataSource.FOR_QUARTZ.jndiURL = java:jdbc/live-quartz
Here is a snippet from the web.xml where the quartz is initialized:
<!-- START NOTIFICATION SERVICE -->
<context-param>
<param-name>config-file</param-name>
<param-value>wm_quartz.properties</param-value>
</context-param>
<context-param>
<param-name>shutdown-on-unload</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>start-scheduler-on-load</param-name>
<param-value>true</param-value>
</context-param>
<listener>
<listener-class>org.quartz.ee.servlet.QuartzInitializerListener</listener-class>
</listener>
Thanks
scheduler. deleteJob(jobKey(<JobKey>, <JobGroup>)); This method will only interrupt/stop the job uniquely identified by the Job Key and Group within the scheduler which may have many other jobs running. scheduler.
It has no built-in UI for configuration or monitoring, no useful and reasonably searchable logging or historical review, no support for multiple execution nodes, no administration interface, no alerts or notifications, not to mention buggy recovery mechanisms for failed jobs and missed jobs.
Quartz scheduler allows an enterprise to schedule a job at a specified date and time. It allows us to perform the operations to schedule or unschedule the jobs. It provides operations to start or stop or pause the scheduler. It also provides reminder services.
If there are any jobs executing when you call shutdown, whether to interrupt those jobs or not depends on the property org.quartz.scheduler.interruptJobsOnShutdown
.
See http://jira.terracotta.org/jira/browse/QTZ-41?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel . I am unable to find more documentation on this.
The other property is org.quartz.scheduler.makeSchedulerThreadDaemon=true
, which will shutdown quartz scheduler as soon as your calling thread shuts down. I do not know what happens to the state of the jobs.
As mentioned in the comments, post some code and configuration to get clear answer.
Please try to apply with these configuration when init scheduler
org.quartz.threadPool.makeThreadsDaemons=true
org.quartz.scheduler.makeSchedulerThreadDaemon=true
org.quartz.scheduler.interruptJobsOnShutdown=true
org.quartz.plugin.shutdownhook.class = org.quartz.plugins.management.ShutdownHookPlugin
org.quartz.plugin.shutdownhook.cleanShutdown = true
You can refer to this link for more detail: https://www.techpaste.com/2016/03/quartz-scheduler-shutdown/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With