我使用DataSource,Spring和Quartz不断耗尽数据库连接。如下所示,我的TaskExecutor的maximumPoolSize为30。那么,这是我的安装程序将使用的最大连接数吗?
在corePoolSize = 10的情况下,我的设置是否连续保持10个数据库连接?
我使用的是这样创建的Spring TaskExecutor,并向我的Spring SchedulerFactoryBean注册。
我这样创建一个TaskExecutor:
public TaskExecutor schedulerTaskExecutor() {
int corePoolSize = 10;
int maxPoolSize = 30;
long keepAliveTime = 30000;
int internalQueueCapacity = 1000;
boolean allowCoreThreadTimeOut = true;
ThreadPoolExecutor threadPool = new ThreadPoolExecutor(
corePoolSize, // core pool size
maxPoolSize, // max pool size
keepAliveTime,
TimeUnit.SECONDS,
new LinkedBlockingQueue<Runnable>(internalQueueCapacity)) ;
threadPool.allowCoreThreadTimeOut(allowCoreThreadTimeOut);
NamedThreadFactory threadFactory = new NamedThreadFactory("SCHEDULER-");
threadPool.setThreadFactory(threadFactory);
return new TaskExecutorAdapter(threadPool);
}