本文整理汇总了Java中org.apache.camel.spi.ThreadPoolProfile.setPoolSize方法的典型用法代码示例。如果您正苦于以下问题:Java ThreadPoolProfile.setPoolSize方法的具体用法?Java ThreadPoolProfile.setPoolSize怎么用?Java ThreadPoolProfile.setPoolSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.camel.spi.ThreadPoolProfile
的用法示例。
在下文中一共展示了ThreadPoolProfile.setPoolSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: threadPoolProfile
import org.apache.camel.spi.ThreadPoolProfile; //导入方法依赖的package包/类
/**
* thread pool of consumer
*/
@Bean(name="defaultThreadPoolProfile")
ThreadPoolProfile threadPoolProfile(){
ThreadPoolProfile defaultThreadPoolProfile = new ThreadPoolProfile();
defaultThreadPoolProfile.setDefaultProfile(true);
defaultThreadPoolProfile.setId("defaultThreadPoolProfile");
defaultThreadPoolProfile.setPoolSize(threadPoolSize);
defaultThreadPoolProfile.setMaxPoolSize(threadMaxPoolSize);
defaultThreadPoolProfile.setMaxQueueSize(threadMaxQueueSize); // 队列最大程度1000万
defaultThreadPoolProfile.setTimeUnit(TimeUnit.SECONDS);
defaultThreadPoolProfile.setKeepAliveTime(60 * 5L);
defaultThreadPoolProfile.setRejectedPolicy(ThreadPoolRejectedPolicy.CallerRuns);
// camelContext().getExecutorServiceManager().registerThreadPoolProfile(defaultThreadPoolProfile);
// setDefaultThreadPoolProfile(defaultThreadPoolProfile);
return defaultThreadPoolProfile;
}
示例2: newThreadPool
import org.apache.camel.spi.ThreadPoolProfile; //导入方法依赖的package包/类
public ExecutorService newThreadPool(Object source, String name, int corePoolSize, int maxPoolSize,
long keepAliveTime, TimeUnit timeUnit, int maxQueueSize,
RejectedExecutionHandler rejectedExecutionHandler, boolean daemon) {
// use a profile with the settings
ThreadPoolProfile profile = new ThreadPoolProfile();
profile.setPoolSize(corePoolSize);
profile.setMaxPoolSize(maxPoolSize);
profile.setMaxQueueSize(maxQueueSize);
profile.setKeepAliveTime(keepAliveTime);
profile.setTimeUnit(timeUnit);
// must cast to ThreadPoolExecutor to be able to set the rejected execution handler
ThreadPoolExecutor answer = (ThreadPoolExecutor) camelContext.getExecutorServiceManager().newThreadPool(source, name, profile);
answer.setRejectedExecutionHandler(rejectedExecutionHandler);
return answer;
}
示例3: createRouteBuilder
import org.apache.camel.spi.ThreadPoolProfile; //导入方法依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
// create and register thread pool profile
ThreadPoolProfile profile = new ThreadPoolProfile("myProfile");
profile.setPoolSize(2);
profile.setMaxPoolSize(8);
profile.setRejectedPolicy(ThreadPoolRejectedPolicy.Abort);
context.getExecutorServiceManager().registerThreadPoolProfile(profile);
from("direct:start")
.aggregate(header("id"), new BodyInAggregatingStrategy())
// use our custom thread pool profile
.completionSize(3).executorServiceRef("myProfile")
.to("log:foo")
.to("mock:aggregated");
}
};
}
示例4: createRouteBuilder
import org.apache.camel.spi.ThreadPoolProfile; //导入方法依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
ThreadPoolProfile profile = new ThreadPoolProfile("custom");
profile.setPoolSize(5);
profile.setMaxPoolSize(15);
profile.setKeepAliveTime(25L);
profile.setMaxQueueSize(250);
profile.setRejectedPolicy(ThreadPoolRejectedPolicy.Abort);
context.getExecutorServiceManager().registerThreadPoolProfile(profile);
from("direct:start").threads().executorServiceRef("custom").to("mock:result");
from("direct:foo").threads().executorServiceRef("custom").to("mock:foo");
}
};
}
示例5: createRouteBuilder
import org.apache.camel.spi.ThreadPoolProfile; //导入方法依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
ThreadPoolProfile profile = new ThreadPoolProfile("custom");
profile.setPoolSize(5);
profile.setMaxPoolSize(15);
profile.setKeepAliveTime(25L);
profile.setMaxQueueSize(250);
profile.setAllowCoreThreadTimeOut(true);
profile.setRejectedPolicy(ThreadPoolRejectedPolicy.Abort);
context.getExecutorServiceManager().registerThreadPoolProfile(profile);
from("direct:start").threads().executorServiceRef("custom").to("mock:result");
}
};
}
示例6: testDefaultUnboundedQueueThreadPool
import org.apache.camel.spi.ThreadPoolProfile; //导入方法依赖的package包/类
public void testDefaultUnboundedQueueThreadPool() throws Exception {
ThreadPoolProfile custom = new ThreadPoolProfile("custom");
custom.setPoolSize(10);
custom.setMaxPoolSize(30);
custom.setKeepAliveTime(50L);
custom.setMaxQueueSize(Integer.MAX_VALUE);
context.getExecutorServiceManager().setDefaultThreadPoolProfile(custom);
assertEquals(true, custom.isDefaultProfile().booleanValue());
ExecutorService myPool = context.getExecutorServiceManager().newDefaultThreadPool(this, "myPool");
assertEquals(false, myPool.isShutdown());
// should use default settings
ThreadPoolExecutor executor = (ThreadPoolExecutor) myPool;
assertEquals(10, executor.getCorePoolSize());
assertEquals(30, executor.getMaximumPoolSize());
assertEquals(50, executor.getKeepAliveTime(TimeUnit.SECONDS));
assertEquals(Integer.MAX_VALUE, executor.getQueue().remainingCapacity());
context.stop();
assertEquals(true, myPool.isShutdown());
}
示例7: testCustomDefaultThreadPool
import org.apache.camel.spi.ThreadPoolProfile; //导入方法依赖的package包/类
public void testCustomDefaultThreadPool() throws Exception {
ThreadPoolProfile custom = new ThreadPoolProfile("custom");
custom.setKeepAliveTime(20L);
custom.setMaxPoolSize(40);
custom.setPoolSize(5);
custom.setMaxQueueSize(2000);
context.getExecutorServiceManager().setDefaultThreadPoolProfile(custom);
assertEquals(true, custom.isDefaultProfile().booleanValue());
ExecutorService myPool = context.getExecutorServiceManager().newDefaultThreadPool(this, "myPool");
assertEquals(false, myPool.isShutdown());
// should use default settings
ThreadPoolExecutor executor = (ThreadPoolExecutor) myPool;
assertEquals(5, executor.getCorePoolSize());
assertEquals(40, executor.getMaximumPoolSize());
assertEquals(20, executor.getKeepAliveTime(TimeUnit.SECONDS));
assertEquals(2000, executor.getQueue().remainingCapacity());
context.stop();
assertEquals(true, myPool.isShutdown());
}
示例8: testTwoGetThreadPoolProfile
import org.apache.camel.spi.ThreadPoolProfile; //导入方法依赖的package包/类
public void testTwoGetThreadPoolProfile() throws Exception {
assertNull(context.getExecutorServiceManager().getThreadPoolProfile("foo"));
ThreadPoolProfile foo = new ThreadPoolProfile("foo");
foo.setKeepAliveTime(20L);
foo.setMaxPoolSize(40);
foo.setPoolSize(5);
foo.setMaxQueueSize(2000);
context.getExecutorServiceManager().registerThreadPoolProfile(foo);
ThreadPoolProfile bar = new ThreadPoolProfile("bar");
bar.setKeepAliveTime(40L);
bar.setMaxPoolSize(5);
bar.setPoolSize(1);
bar.setMaxQueueSize(100);
context.getExecutorServiceManager().registerThreadPoolProfile(bar);
assertSame(foo, context.getExecutorServiceManager().getThreadPoolProfile("foo"));
assertSame(bar, context.getExecutorServiceManager().getThreadPoolProfile("bar"));
assertNotSame(foo, bar);
assertFalse(context.getExecutorServiceManager().getThreadPoolProfile("foo").isDefaultProfile());
assertFalse(context.getExecutorServiceManager().getThreadPoolProfile("bar").isDefaultProfile());
}
示例9: testGetThreadPoolProfileInheritCustomDefaultValues
import org.apache.camel.spi.ThreadPoolProfile; //导入方法依赖的package包/类
public void testGetThreadPoolProfileInheritCustomDefaultValues() throws Exception {
ThreadPoolProfile newDefault = new ThreadPoolProfile("newDefault");
newDefault.setKeepAliveTime(30L);
newDefault.setMaxPoolSize(50);
newDefault.setPoolSize(5);
newDefault.setMaxQueueSize(2000);
newDefault.setRejectedPolicy(ThreadPoolRejectedPolicy.Abort);
context.getExecutorServiceManager().setDefaultThreadPoolProfile(newDefault);
assertNull(context.getExecutorServiceManager().getThreadPoolProfile("foo"));
ThreadPoolProfile foo = new ThreadPoolProfile("foo");
foo.setMaxPoolSize(25);
foo.setPoolSize(1);
context.getExecutorServiceManager().registerThreadPoolProfile(foo);
assertSame(foo, context.getExecutorServiceManager().getThreadPoolProfile("foo"));
ExecutorService executor = context.getExecutorServiceManager().newThreadPool(this, "MyPool", "foo");
ThreadPoolExecutor tp = assertIsInstanceOf(ThreadPoolExecutor.class, executor);
assertEquals(25, tp.getMaximumPoolSize());
// should inherit the default values
assertEquals(1, tp.getCorePoolSize());
assertEquals(30, tp.getKeepAliveTime(TimeUnit.SECONDS));
assertEquals("Abort", tp.getRejectedExecutionHandler().toString());
}
示例10: testNewScheduledThreadPoolProfileById
import org.apache.camel.spi.ThreadPoolProfile; //导入方法依赖的package包/类
public void testNewScheduledThreadPoolProfileById() throws Exception {
assertNull(context.getExecutorServiceManager().getThreadPoolProfile("foo"));
ThreadPoolProfile foo = new ThreadPoolProfile("foo");
foo.setKeepAliveTime(20L);
foo.setMaxPoolSize(40);
foo.setPoolSize(5);
foo.setMaxQueueSize(2000);
context.getExecutorServiceManager().registerThreadPoolProfile(foo);
ExecutorService pool = context.getExecutorServiceManager().newScheduledThreadPool(this, "Cool", "foo");
assertNotNull(pool);
SizedScheduledExecutorService tp = assertIsInstanceOf(SizedScheduledExecutorService.class, pool);
// a scheduled dont use keep alive
assertEquals(0, tp.getKeepAliveTime(TimeUnit.SECONDS));
assertEquals(Integer.MAX_VALUE, tp.getMaximumPoolSize());
assertEquals(5, tp.getCorePoolSize());
assertFalse(tp.isShutdown());
context.stop();
assertTrue(tp.isShutdown());
}
示例11: testNewThreadPoolProfile
import org.apache.camel.spi.ThreadPoolProfile; //导入方法依赖的package包/类
public void testNewThreadPoolProfile() throws Exception {
assertNull(context.getExecutorServiceManager().getThreadPoolProfile("foo"));
ThreadPoolProfile foo = new ThreadPoolProfile("foo");
foo.setKeepAliveTime(20L);
foo.setMaxPoolSize(40);
foo.setPoolSize(5);
foo.setMaxQueueSize(2000);
ExecutorService pool = context.getExecutorServiceManager().newThreadPool(this, "Cool", foo);
assertNotNull(pool);
ThreadPoolExecutor tp = assertIsInstanceOf(ThreadPoolExecutor.class, pool);
assertEquals(20, tp.getKeepAliveTime(TimeUnit.SECONDS));
assertEquals(40, tp.getMaximumPoolSize());
assertEquals(5, tp.getCorePoolSize());
assertFalse(tp.isShutdown());
context.stop();
assertTrue(tp.isShutdown());
}
示例12: testNewThreadPoolProfileById
import org.apache.camel.spi.ThreadPoolProfile; //导入方法依赖的package包/类
public void testNewThreadPoolProfileById() throws Exception {
assertNull(context.getExecutorServiceManager().getThreadPoolProfile("foo"));
ThreadPoolProfile foo = new ThreadPoolProfile("foo");
foo.setKeepAliveTime(20L);
foo.setMaxPoolSize(40);
foo.setPoolSize(5);
foo.setMaxQueueSize(2000);
context.getExecutorServiceManager().registerThreadPoolProfile(foo);
ExecutorService pool = context.getExecutorServiceManager().newThreadPool(this, "Cool", "foo");
assertNotNull(pool);
ThreadPoolExecutor tp = assertIsInstanceOf(ThreadPoolExecutor.class, pool);
assertEquals(20, tp.getKeepAliveTime(TimeUnit.SECONDS));
assertEquals(40, tp.getMaximumPoolSize());
assertEquals(5, tp.getCorePoolSize());
assertFalse(tp.isShutdown());
context.stop();
assertTrue(tp.isShutdown());
}
示例13: threadPoolProfileRemote
import org.apache.camel.spi.ThreadPoolProfile; //导入方法依赖的package包/类
private ThreadPoolProfile threadPoolProfileRemote() {
//Define custom thread pool profile
ThreadPoolProfile threadPoolProfile = new ThreadPoolProfile("openex-remote-thread-profile");
threadPoolProfile.setPoolSize(10);
threadPoolProfile.setMaxPoolSize(20);
threadPoolProfile.setMaxQueueSize(500);
threadPoolProfile.setAllowCoreThreadTimeOut(false);
threadPoolProfile.setRejectedPolicy(ThreadPoolRejectedPolicy.Discard);
return threadPoolProfile;
}
示例14: threadPoolProfileExecutor
import org.apache.camel.spi.ThreadPoolProfile; //导入方法依赖的package包/类
private ThreadPoolProfile threadPoolProfileExecutor() {
//Define custom thread pool profile
ThreadPoolProfile threadPoolProfile = new ThreadPoolProfile("openex-worker-thread-profile");
threadPoolProfile.setPoolSize(20);
threadPoolProfile.setMaxPoolSize(40);
threadPoolProfile.setMaxQueueSize(1000);
threadPoolProfile.setAllowCoreThreadTimeOut(false);
threadPoolProfile.setRejectedPolicy(ThreadPoolRejectedPolicy.CallerRuns);
return threadPoolProfile;
}
示例15: DefaultExecutorServiceManager
import org.apache.camel.spi.ThreadPoolProfile; //导入方法依赖的package包/类
public DefaultExecutorServiceManager(CamelContext camelContext) {
this.camelContext = camelContext;
defaultProfile = new ThreadPoolProfile(defaultThreadPoolProfileId);
defaultProfile.setDefaultProfile(true);
defaultProfile.setPoolSize(10);
defaultProfile.setMaxPoolSize(20);
defaultProfile.setKeepAliveTime(60L);
defaultProfile.setTimeUnit(TimeUnit.SECONDS);
defaultProfile.setMaxQueueSize(1000);
defaultProfile.setAllowCoreThreadTimeOut(false);
defaultProfile.setRejectedPolicy(ThreadPoolRejectedPolicy.CallerRuns);
registerThreadPoolProfile(defaultProfile);
}