use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project spring-framework by spring-projects.
the class AbstractMessageBrokerConfiguration method clientOutboundChannelExecutor.
@Bean
public ThreadPoolTaskExecutor clientOutboundChannelExecutor() {
TaskExecutorRegistration reg = getClientOutboundChannelRegistration().getOrCreateTaskExecRegistration();
ThreadPoolTaskExecutor executor = reg.getTaskExecutor();
executor.setThreadNamePrefix("clientOutboundChannel-");
return executor;
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project spring-framework by spring-projects.
the class TaskExecutorRegistration method getTaskExecutor.
protected ThreadPoolTaskExecutor getTaskExecutor() {
ThreadPoolTaskExecutor executor = (this.taskExecutor != null ? this.taskExecutor : new ThreadPoolTaskExecutor());
executor.setCorePoolSize(this.corePoolSize);
executor.setMaxPoolSize(this.maxPoolSize);
executor.setKeepAliveSeconds(this.keepAliveSeconds);
executor.setQueueCapacity(this.queueCapacity);
executor.setAllowCoreThreadTimeOut(true);
return executor;
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project spring-framework by spring-projects.
the class GenericMessagingTemplateTests method setup.
@Before
public void setup() {
this.messageChannel = new StubMessageChannel();
this.template = new GenericMessagingTemplate();
this.template.setDefaultDestination(this.messageChannel);
this.template.setDestinationResolver(new TestDestinationResolver());
this.executor = new ThreadPoolTaskExecutor();
this.executor.afterPropertiesSet();
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project spring-framework by spring-projects.
the class MessageBrokerConfigurationTests method clientOutboundChannelCustomized.
@Test
public void clientOutboundChannelCustomized() {
AbstractSubscribableChannel channel = this.customContext.getBean("clientOutboundChannel", AbstractSubscribableChannel.class);
assertEquals(3, channel.getInterceptors().size());
ThreadPoolTaskExecutor taskExecutor = this.customContext.getBean("clientOutboundChannelExecutor", ThreadPoolTaskExecutor.class);
assertEquals(21, taskExecutor.getCorePoolSize());
assertEquals(22, taskExecutor.getMaxPoolSize());
assertEquals(23, taskExecutor.getKeepAliveSeconds());
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project camel by apache.
the class XQueryURLBasedConcurrencyTest method testConcurrency.
@Test
public void testConcurrency() throws Exception {
int total = 1000;
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(total);
// setup a task executor to be able send the messages in parallel
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(5);
executor.afterPropertiesSet();
for (int i = 0; i < 5; i++) {
final int threadCount = i;
executor.execute(new Runnable() {
public void run() {
int start = threadCount * 200;
for (int i = 0; i < 200; i++) {
try {
// do some random sleep to simulate spread in user activity
Thread.sleep(new Random().nextInt(10));
} catch (InterruptedException e) {
// ignore
}
template.sendBody("direct:start", "<mail><subject>" + (start + i) + "</subject><body>Hello world!</body></mail>");
}
}
});
}
mock.assertIsSatisfied();
// must use bodyAs(String.class) to force DOM to be converted to String XML
// for duplication detection
mock.assertNoDuplicates(bodyAs(String.class));
executor.shutdown();
}
Aggregations