quartz 使用配置文件配置線程數
quartz默認的線程數是10個,如果我們要修改這個線程數需要做一個配置文件,在配置文件內修改線程。
一共需要2個操作:
1、找到quartz的XML配置文件,設置加載配置文件(配置文件存放在webapp項目下的資源文件內即可)
<bean id="****"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="*****" />
</list>
</property>
<property name="configLocation" value="classpath:quartz.properties"/>
</bean>
2、quartz.properties配置文件
org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount=15
org.quartz.threadPool.threadPriority=5
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread=true
org.quartz.jobStore.misfireThreshold=60000
org.quartz.jobStore.class=org.quartz.simpl.RAMJobStore
設置以上參數後,在項目啟動後就可以看到如下信息了
Scheduler meta-data: Quartz Scheduler (v2.2.1) ‘schedulerFactoryBean‘ 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 15 threads.
Using job-store ‘org.quartz.simpl.RAMJobStore‘ - which does not support persistence. and is not clustered.
quartz 使用配置文件配置線程數