How to make sure quartz.properties is used?

I set the following properties in quartz.properties file:

org.quartz.threadPool.threadCount = 60 org.quartz.scheduler.batchTriggerAcquisitionMaxCount = 60 

however, for some reason, it does not appear to enter into force. because when I run my application, the log shows that it is still using 1 thread in the pool:

 [main] INFO org.quartz.impl.StdSchedulerFactory - Using default implementation for ThreadExecutor [main] INFO org.quartz.core.SchedulerSignalerImpl - Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl [main] INFO org.quartz.core.QuartzScheduler - Quartz Scheduler v.2.1.1 created. [main] INFO org.quartz.simpl.RAMJobStore - RAMJobStore initialized. [main] INFO org.quartz.core.QuartzScheduler - Scheduler meta-data: Quartz Scheduler (v2.1.1) 'QuartzScheduler' with instanceId 'NON_CLUSTERED' Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally. NOT STARTED. Currently in standby mode. Number of jobs executed: 0 Using **thread pool 'org.quartz.simpl.SimpleThreadPool' - with 1 threads.** 

I know that quartz.properties should be on the path of the class to find. and I just did it. any other reason why this file is not found? or is it detected, but the number of threads is set incorrectly?

thanks

+4
source share
2 answers

oops, I found a problem, in fact, the code redefined the configuration of the properties file by creating an instance of the properties class in the code . so the answer will be like this:

sf = new StdSchedulerFactory("conf/quartz.properties");

+1
source

For those who use Spring + Quartz and quartz.properties file does not work (i.e., is ignored when the application starts):

The Quartz Scheduler ( org.quartz.Scheduler ) created by the Spring Factory Bean ( org.springframework.scheduling.quartz.SchedulerFactoryBean ) will not read the quartz.properties file from the default class path, as stated in the Quartz docs - you need to set the link manually:

[in case of Java configuration]:

 @Bean public SchedulerFactoryBean schedulerFactoryBean() { SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean(); schedulerFactoryBean.setConfigLocation(new ClassPathResource("quartz.properties")); // ... } 

[in case of XML configuration]:

 <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="configLocation" value="classpath:quartz.properties" /> // ... </bean> 
+5
source

All Articles