I've got a job that needs to be run every 1 minute. I've decided to move from Spring's @Scheduled annotation to Quartz jobs to take advantage of its clustered mode during blue/green deployment. For that I used a configuration similar to this:
@Bean
public JobDetailFactoryBean fooJob() {
JobDetailFactoryBean factoryBean = new JobDetailFactoryBean();
factoryBean.setJobClass(FooJob.class);
factoryBean.setName(JOB_IDENTITY);
factoryBean.setGroup(FooJob.class.getName());
factoryBean.setDurability(true);
return factoryBean;
}
@Bean
public SimpleTriggerFactoryBean fooTrigger(@Qualifier("fooJob") JobDetail jobDetail) {
SimpleTriggerFactoryBean factoryBean = new SimpleTriggerFactoryBean();
factoryBean.setName(JOB_IDENTITY);
factoryBean.setGroup(FooJob.class.getName());
factoryBean.setJobDetail(jobDetail);
factoryBean.setStartDelay(0L);
factoryBean.setRepeatInterval(INTERVAL_SECONDS * 1000);
factoryBean.setMisfireInstruction(Trigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY);
return factoryBean;
}
Also I've got a postgres job store configured. Nothing wrong here - it works as expected.
Now my question is: what if in some time in the future I don't need this job run anymore? Then I remove this configuration but the job and the trigger are still persisted in the job store and the job is run even though the configuration is removed. My expectation is that when I deploy a code with no beans from above, then the job is removed from the store. Is it somehow possible?