I have a quartz job that runs continuously. It looks for a new file every 5 minutes, processes it (whenever it finds it) and then keeps going forever. In the event that we want to do system maintenance, or shut it down cleanly, I want to allow the job in process to finish, and then stop the scheduler. Using the SchedulerFactoryBean with a CronTriggerBean, I'm not sure how I would allow the scheduler to know that after completing a job, it's time to quit. Here is my configuration:
Once I'm in the executeInternal() method of the JobLauncherDetails class, could trap something (or listen to something) to tell the scheduler to stop, since I have access to it via:Code:<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="triggers"> <bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> <property name="jobDetail" ref="jobDetail" /> <property name="cronExpression" value="0 0/5 * * * ?" /> </bean> </property> </bean> <bean id="jobDetail" class="org.springframework.scheduling.quartz.JobDetailBean"> <property name="jobClass" value="my.JobLauncherDetails" /> <property name="group" value="batch" /> <property name="jobDataAsMap"> <map> <entry key="jobName" value="myJob"/> <entry key="jobLocator" value-ref="jobRegistry"/> <entry key="jobLauncher" value-ref="jobLauncher"/> <entry key="fileWatcher" value-ref="myWatcher"/> </map> </property> </bean>
What I was curious to know is what others have used, or I could use to listen to. I hate to create a message queue and have it running for just this purpose. Any other ideas?Code:protected void executeInternal(JobExecutionContext context) { if (shutdownSignalReceivedSomehow) { context.getScheduler().shutdown() } }
Brian


Reply With Quote