use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project spring-framework by spring-projects.
the class TestValidator method testExecutor.
private void testExecutor(String channelName, int corePoolSize, int maxPoolSize, int keepAliveSeconds) {
ThreadPoolTaskExecutor taskExecutor = this.appContext.getBean(channelName + "Executor", ThreadPoolTaskExecutor.class);
assertEquals(corePoolSize, taskExecutor.getCorePoolSize());
assertEquals(maxPoolSize, taskExecutor.getMaxPoolSize());
assertEquals(keepAliveSeconds, taskExecutor.getKeepAliveSeconds());
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project spring-framework by spring-projects.
the class AbstractMessageBrokerConfiguration method clientInboundChannelExecutor.
@Bean
public ThreadPoolTaskExecutor clientInboundChannelExecutor() {
TaskExecutorRegistration reg = getClientInboundChannelRegistration().getOrCreateTaskExecRegistration();
ThreadPoolTaskExecutor executor = reg.getTaskExecutor();
executor.setThreadNamePrefix("clientInboundChannel-");
return executor;
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project spring-framework by spring-projects.
the class TaskExecutorFactoryBean method afterPropertiesSet.
@Override
public void afterPropertiesSet() {
this.target = new ThreadPoolTaskExecutor();
determinePoolSizeRange();
if (this.queueCapacity != null) {
this.target.setQueueCapacity(this.queueCapacity);
}
if (this.keepAliveSeconds != null) {
this.target.setKeepAliveSeconds(this.keepAliveSeconds);
}
if (this.rejectedExecutionHandler != null) {
this.target.setRejectedExecutionHandler(this.rejectedExecutionHandler);
}
if (this.beanName != null) {
this.target.setThreadNamePrefix(this.beanName + "-");
}
this.target.afterPropertiesSet();
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project spring-framework by spring-projects.
the class AsyncAnnotationBeanPostProcessorTests method threadNamePrefix.
@Test
public void threadNamePrefix() {
BeanDefinition processorDefinition = new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.class);
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setThreadNamePrefix("testExecutor");
executor.afterPropertiesSet();
processorDefinition.getPropertyValues().add("executor", executor);
ConfigurableApplicationContext context = initContext(processorDefinition);
ITestBean testBean = context.getBean("target", ITestBean.class);
testBean.test();
testBean.await(3000);
Thread asyncThread = testBean.getThread();
assertTrue(asyncThread.getName().startsWith("testExecutor"));
context.close();
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project spring-framework by spring-projects.
the class MessageBrokerConfigurationTests method threadPoolSizeDefault.
@Test
public void threadPoolSizeDefault() {
String name = "clientInboundChannelExecutor";
ThreadPoolTaskExecutor executor = this.defaultContext.getBean(name, ThreadPoolTaskExecutor.class);
assertEquals(Runtime.getRuntime().availableProcessors() * 2, executor.getCorePoolSize());
// No way to verify queue capacity
name = "clientOutboundChannelExecutor";
executor = this.defaultContext.getBean(name, ThreadPoolTaskExecutor.class);
assertEquals(Runtime.getRuntime().availableProcessors() * 2, executor.getCorePoolSize());
name = "brokerChannelExecutor";
executor = this.defaultContext.getBean(name, ThreadPoolTaskExecutor.class);
assertEquals(0, executor.getCorePoolSize());
assertEquals(1, executor.getMaxPoolSize());
}
Aggregations