use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project zipkin by openzipkin.
the class ZipkinMySQLStorageAutoConfiguration method executor.
@Bean
@ConditionalOnMissingBean(Executor.class)
Executor executor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setThreadNamePrefix("ZipkinMySQLStorage-");
executor.initialize();
return executor;
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project camel by apache.
the class DefaultJmsMessageListenerContainer method stop.
@Override
public void stop() throws JmsException {
if (logger.isDebugEnabled()) {
logger.debug("Stopping listenerContainer: " + this + " with cacheLevel: " + getCacheLevel() + " and sharedConnectionEnabled: " + sharedConnectionEnabled());
}
super.stop();
if (taskExecutor instanceof ThreadPoolTaskExecutor) {
ThreadPoolTaskExecutor executor = (ThreadPoolTaskExecutor) taskExecutor;
executor.destroy();
}
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project ocvn by devgateway.
the class AsyncConfiguration method getAsyncExecutor.
@Bean
@Override
public ThreadPoolTaskExecutor getAsyncExecutor() {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setMaxPoolSize(1);
taskExecutor.setThreadNamePrefix("VNImportServiceExecutor-");
return taskExecutor;
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project camel by apache.
the class JmsConcurrentConsumersTest method testConcurrentConsumersWithReply.
@Test
public void testConcurrentConsumersWithReply() throws Exception {
// latch for the 5 exchanges we expect
final CountDownLatch latch = new CountDownLatch(5);
// 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 count = i;
executor.execute(new Runnable() {
public void run() {
// request body is InOut pattern and thus we expect a reply (JMSReply)
Object response = template.requestBody("activemq:a", "World #" + count);
assertEquals("Bye World #" + count, response);
latch.countDown();
}
});
}
long start = System.currentTimeMillis();
// wait for test completion, timeout after 30 sec to let other unit test run to not wait forever
assertTrue(latch.await(30000L, TimeUnit.MILLISECONDS));
assertEquals("Latch should be zero", 0, latch.getCount());
long delta = System.currentTimeMillis() - start;
assertTrue("Should be faster than 20000 millis, took " + delta + " millis", delta < 20000L);
executor.shutdown();
}
use of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor in project metacat by Netflix.
the class CommonServerConfig method taskExecutor.
/**
* Get a task executor for executing tasks asynchronously that don't need to be scheduled at a recurring rate.
*
* @param metacatProperties The metacat properties to get number of executor threads from.
* Likely best to do one more than number of CPUs
* @return The task executor the system to use
*/
@Bean
public AsyncTaskExecutor taskExecutor(final MetacatProperties metacatProperties) {
final ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(metacatProperties.getEvent().getBus().getExecutor().getThread().getCount());
return executor;
}
Aggregations