Java Code Examples for org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean#setQueueCapacity()

The following examples show how to use org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean#setQueueCapacity() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExecutorConfiguration.java    From spring-data-dev-tools with Apache License 2.0 5 votes vote down vote up
@Bean
public ThreadPoolExecutorFactoryBean executorService() {

	int processors = Runtime.getRuntime().availableProcessors();
	int threadCount = Math.max(2, processors - 4);
	log.info(String.format("Setting up Executor Service with %d Threads", threadCount));

	ThreadPoolExecutorFactoryBean scheduler = new ThreadPoolExecutorFactoryBean();
	scheduler.setCorePoolSize(threadCount);
	scheduler.setQueueCapacity(32);

	return scheduler;
}
 
Example 2
Source File: Application.java    From chaos-lemur with Apache License 2.0 5 votes vote down vote up
@Bean(destroyMethod = "shutdown")
ThreadPoolExecutorFactoryBean executor() {
    ThreadPoolExecutorFactoryBean factoryBean = new ThreadPoolExecutorFactoryBean();
    factoryBean.setQueueCapacity(5);
    factoryBean.setCorePoolSize(5);
    factoryBean.setMaxPoolSize(20);
    factoryBean.setThreadNamePrefix("destroyer-");

    return factoryBean;
}
 
Example 3
Source File: AppConfig.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Bean
public ThreadPoolExecutorFactoryBean getThreadPoolExecutorFactoryBean() {
    ThreadPoolExecutorFactoryBean executorFactoryBean = new ThreadPoolExecutorFactoryBean();
    executorFactoryBean.setCorePoolSize(corePoolSize);
    executorFactoryBean.setMaxPoolSize(maxPoolSize);
    executorFactoryBean.setQueueCapacity(queueCapacity);
    executorFactoryBean.setRejectedExecutionHandler(persistRejectedThreadExecutionHandler);
    return executorFactoryBean;
}
 
Example 4
Source File: RejectedThreadContext.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Bean
public ThreadPoolExecutorFactoryBean getThreadPoolExecutorFactoryBean() {
    ThreadPoolExecutorFactoryBean executorFactoryBean = new ThreadPoolExecutorFactoryBean();
    executorFactoryBean.setCorePoolSize(1);
    executorFactoryBean.setMaxPoolSize(2);
    executorFactoryBean.setQueueCapacity(2);
    executorFactoryBean.setRejectedExecutionHandler(persistRejectedThreadExecutionHandler);
    return executorFactoryBean;
}
 
Example 5
Source File: StackCollectorContext.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
@Bean
public ThreadPoolExecutorFactoryBean getThreadPoolExecutorFactoryBean() {
    ThreadPoolExecutorFactoryBean executorFactoryBean = new ThreadPoolExecutorFactoryBean();
    executorFactoryBean.setCorePoolSize(1);
    executorFactoryBean.setMaxPoolSize(2);
    executorFactoryBean.setQueueCapacity(2);
    executorFactoryBean.setRejectedExecutionHandler(persistRejectedThreadExecutionHandler);
    return executorFactoryBean;
}