- /**
- * Shutdown the scheduler
- */
- privatevoid shutdownScheduler(){
- try{
- log.info("Performing Job Resources CleanUp");
- Scheduler scheduler = SchedulerManager.getInstance().getScheduler();
- if(scheduler !=null){
- List jobExeContextList = scheduler.getCurrentlyExecutingJobs();
- log.info("There are "+ jobExeContextList.size()+" running
- jobs at shutdown.");
- Iterator it = jobExeContextList.iterator();
- while(it.hasNext()){
- JobExecutionContext jobExeContext =(JobExecutionContext) it.next();
- BasicJob job =(BasicJob) jobExeContext.getJobInstance();
- job.cleanup();
- }
- log.info("Shutting down Quartz Scheduler...");
- scheduler.shutdown(true);
- }else{
- log.info("Quartz Scheduler is not running");
- }
- }catch(Exception e){
- log.info("Error shutting down Quartz: "+ e.getMessage(), e);
- }
- }
↧
How to cleanup Quartz Jobs on shutdown in Java?
↧