Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set thread count for quartz thread pool

I have created file quartz.properties and put it in classpath. The properties are

org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 1

But when I start the application I get this message

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 10 threads.
Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.

Does it load property or no? I run only one thread for scheduler anyway...

like image 229
lapots Avatar asked Apr 20 '17 08:04

lapots


4 Answers

@NikNik

org.quartz.threadPool.threadCount datatype must be String so It Should be

p.put("org.quartz.threadPool.threadCount", "2");

...

StdSchedulerFactory factory = new StdSchedulerFactory(p);
like image 59
vikas ray Avatar answered Nov 15 '22 03:11

vikas ray


With Spring Boot 2.1.4 I was able to set the thread pool size with the following property:

spring.quartz.properties.org.quartz.threadPool.threadCount=2

like image 39
Fervento Avatar answered Nov 15 '22 04:11

Fervento


As I am using spring I did like this. I created in my common properties file a property

quartz.threadPool.threadCount=1

And then set the field quartzProperties of ScheduleFactoryBean in my xml

<property name="quartzProperties">
    <util:properties>
        <prop key="org.quartz.threadPool.threadCount">
            ${quartz.threadPool.threadCount}
        </prop>
    </util:properties>
</property>
like image 26
lapots Avatar answered Nov 15 '22 03:11

lapots


If You are using Annotated Spring Configuration:

@Bean
public SchedulerFactoryBean schedulerFactoryBean() {        
    SchedulerFactoryBean scheduler = new SchedulerFactoryBean();
    Properties quartzProperties = new Properties();     
    quartzProperties.put("org.quartz.threadPool.threadCount", "1");
    scheduler.setQuartzProperties(quartzProperties);
    ...
    return scheduler;
}
like image 45
Tonino Avatar answered Nov 15 '22 04:11

Tonino