Search code examples
javaspring-bootquartz-scheduler

How to make a node able only to schedule Quartz jobs instead of executing them?


I have two Java Spring-Boot services, A and B, for which I need A to create Quartz jobs so B can fire them. B can schedule jobs as well, as long as A doesn't fire any.

I checked Quartz's configuration guide (http://www.quartz-scheduler.org/documentation/quartz-2.1.7/configuration/ConfigMain.html), but didn't find something meaningful there. I tried setting org.quartz.scheduler .batchTriggerAcquisitionMaxCount=0, but A was still able to fire triggers. Is there some property or anything that can support this?


Solution

  • I could achieve the desired behavior by setting the auto start-up property in the scheduler factory bean programatically. The code below should work:

    @Configuration
    public class QuartzConfig {
        @Autowired
        public void unsetAutoStartup(
            SchedulerFactoryBean schedulerFactoryBean
        ) {
            schedulerFactoryBean.setAutoStartup(false);
        }
    }
    

    This application is able to schedule jobs, but won't pick up any for execution.