use of org.apache.camel.spi.ThreadPoolProfile in project camel by apache.
the class SpringCamelContextThreadPoolProfilesTest method testLowProfile.
public void testLowProfile() throws Exception {
CamelContext context = getMandatoryBean(CamelContext.class, "camel-C");
ThreadPoolProfile profile = context.getExecutorServiceManager().getThreadPoolProfile("low");
assertEquals(1, profile.getPoolSize().intValue());
assertEquals(5, profile.getMaxPoolSize().intValue());
assertEquals(null, profile.getKeepAliveTime());
assertEquals(null, profile.getMaxQueueSize());
assertEquals(null, profile.getRejectedPolicy());
// create a thread pool from low
ExecutorService executor = context.getExecutorServiceManager().newThreadPool(this, "MyLow", "low");
ThreadPoolExecutor tp = assertIsInstanceOf(ThreadPoolExecutor.class, executor);
assertEquals(1, tp.getCorePoolSize());
assertEquals(5, tp.getMaximumPoolSize());
// should inherit default options
assertEquals(60, tp.getKeepAliveTime(TimeUnit.SECONDS));
assertEquals("CallerRuns", tp.getRejectedExecutionHandler().toString());
}
use of org.apache.camel.spi.ThreadPoolProfile in project camel by apache.
the class SpringCamelContextCustomDefaultThreadPoolProfileTest method testDefaultThreadPoolProfile.
public void testDefaultThreadPoolProfile() throws Exception {
SpringCamelContext context = applicationContext.getBeansOfType(SpringCamelContext.class).values().iterator().next();
ThreadPoolProfile profile = context.getExecutorServiceManager().getDefaultThreadPoolProfile();
assertEquals(5, profile.getPoolSize().intValue());
assertEquals(15, profile.getMaxPoolSize().intValue());
assertEquals(25, profile.getKeepAliveTime().longValue());
assertEquals(250, profile.getMaxQueueSize().intValue());
assertEquals(true, profile.getAllowCoreThreadTimeOut().booleanValue());
assertEquals(ThreadPoolRejectedPolicy.Abort, profile.getRejectedPolicy());
}
use of org.apache.camel.spi.ThreadPoolProfile in project camel by apache.
the class SpringCamelContextCustomThreadPoolProfileTest method testDefaultThreadPoolProfile.
public void testDefaultThreadPoolProfile() throws Exception {
CamelContext context = getMandatoryBean(CamelContext.class, "camel-D");
ThreadPoolProfile profile = context.getExecutorServiceManager().getDefaultThreadPoolProfile();
assertEquals(5, profile.getPoolSize().intValue());
assertEquals(15, profile.getMaxPoolSize().intValue());
assertEquals(25, profile.getKeepAliveTime().longValue());
assertEquals(250, profile.getMaxQueueSize().intValue());
assertEquals(ThreadPoolRejectedPolicy.Abort, profile.getRejectedPolicy());
}
use of org.apache.camel.spi.ThreadPoolProfile in project camel by apache.
the class SpringCamelContextSimpleCustomDefaultThreadPoolProfileTest method testDefaultThreadPoolProfile.
public void testDefaultThreadPoolProfile() throws Exception {
CamelContext context = getMandatoryBean(CamelContext.class, "camel-B");
ThreadPoolProfile profile = context.getExecutorServiceManager().getDefaultThreadPoolProfile();
assertEquals(25, profile.getMaxPoolSize().intValue());
// should inherit default values
assertEquals(10, profile.getPoolSize().intValue());
assertEquals(60, profile.getKeepAliveTime().longValue());
assertEquals(1000, profile.getMaxQueueSize().intValue());
assertEquals(ThreadPoolRejectedPolicy.CallerRuns, profile.getRejectedPolicy());
}
use of org.apache.camel.spi.ThreadPoolProfile in project camel by apache.
the class FacebookProducer method getExecutorService.
protected static synchronized ExecutorService getExecutorService(CamelContext context) {
// re-create it (its a shared static instance)
if (executorService == null || executorService.isTerminated() || executorService.isShutdown()) {
final ExecutorServiceManager manager = context.getExecutorServiceManager();
// try to lookup a pool first based on profile
ThreadPoolProfile poolProfile = manager.getThreadPoolProfile(FacebookConstants.FACEBOOK_THREAD_PROFILE_NAME);
if (poolProfile == null) {
poolProfile = manager.getDefaultThreadPoolProfile();
}
// create a new pool using the custom or default profile
executorService = manager.newScheduledThreadPool(FacebookProducer.class, FacebookConstants.FACEBOOK_THREAD_PROFILE_NAME, poolProfile);
}
return executorService;
}
Aggregations