I have a service which uses Quartz scheduler, its deployed in kubernetes in clustered mode.
I need all the instances to be able to create tasks to the quartz, but only some of them to be act as workers to run the job and remaining just for managing the jobs (managers). Managers should be able to add tasks but the jobs should not run on them. The code deployed on both of them are same, only changes should be on the configurations.
I tried this
public class QuartzSchedulerFactoryBean extends SchedulerFactoryBean {
@Autowired
AppConfiguration configuration;
@Override
public void afterPropertiesSet() throws Exception {
if(configuration.getQuartzWorkerEnabled())
super.afterPropertiesSet();
}
}
But this will disable the scheduler also, so that I cannot add tasks to the quartz.
I tried setting threadCount to 0 but that will give error starting the quartz.
Use a different configuration file for the manager and scheduler.
For manager use the ZeroSizeThreadpool
Sometimes this may throw an error
no setter found for threadCountIn that case define a custom threadpool extending ZeroSizeThreadPool