当前位置: 首页>>代码示例>>Java>>正文


Java ThreadPoolProfile.setRejectedPolicy方法代码示例

本文整理汇总了Java中org.apache.camel.spi.ThreadPoolProfile.setRejectedPolicy方法的典型用法代码示例。如果您正苦于以下问题:Java ThreadPoolProfile.setRejectedPolicy方法的具体用法?Java ThreadPoolProfile.setRejectedPolicy怎么用?Java ThreadPoolProfile.setRejectedPolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.camel.spi.ThreadPoolProfile的用法示例。


在下文中一共展示了ThreadPoolProfile.setRejectedPolicy方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
	}
 
开发者ID:eXcellme,项目名称:eds,代码行数:19,代码来源:EdsCamelConfig.java

示例2: 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");
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:AggregateThreadPoolProfileTest.java

示例3: 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");
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:DualManagedThreadPoolProfileTest.java

示例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.setAllowCoreThreadTimeOut(true);
            profile.setRejectedPolicy(ThreadPoolRejectedPolicy.Abort);

            context.getExecutorServiceManager().registerThreadPoolProfile(profile);

            from("direct:start").threads().executorServiceRef("custom").to("mock:result");
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:ManagedThreadPoolProfileTest.java

示例5: 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());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:26,代码来源:DefaultExecutorServiceManagerTest.java

示例6: 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;
}
 
开发者ID:LuatixHQ,项目名称:openex-worker,代码行数:11,代码来源:OpenexContext.java

示例7: 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;
}
 
开发者ID:LuatixHQ,项目名称:openex-worker,代码行数:11,代码来源:OpenexContext.java

示例8: 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);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:16,代码来源:DefaultExecutorServiceManager.java

示例9: createCamelContext

import org.apache.camel.spi.ThreadPoolProfile; //导入方法依赖的package包/类
@Override
protected CamelContext createCamelContext() throws Exception {
    CamelContext camel = super.createCamelContext();

    ThreadPoolProfile profile = new ThreadPoolProfile("custom");
    profile.setPoolSize(5);
    profile.setMaxPoolSize(15);
    profile.setKeepAliveTime(25L);
    profile.setMaxQueueSize(250);
    profile.setAllowCoreThreadTimeOut(true);
    profile.setRejectedPolicy(ThreadPoolRejectedPolicy.Abort);

    camel.getExecutorServiceManager().setDefaultThreadPoolProfile(profile);
    return camel;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:16,代码来源:CamelCustomDefaultThreadPoolProfileTest.java

示例10: asThreadPoolProfile

import org.apache.camel.spi.ThreadPoolProfile; //导入方法依赖的package包/类
/**
 * Creates a {@link ThreadPoolProfile} instance based on the definition.
 *
 * @param context    the camel context
 * @return           the profile
 * @throws Exception is thrown if error creating the profile
 */
private ThreadPoolProfile asThreadPoolProfile(CamelContext context, ThreadPoolProfileDefinition definition) throws Exception {
    ThreadPoolProfile answer = new ThreadPoolProfile();
    answer.setId(definition.getId());
    answer.setDefaultProfile(definition.getDefaultProfile());
    answer.setPoolSize(CamelContextHelper.parseInteger(context, definition.getPoolSize()));
    answer.setMaxPoolSize(CamelContextHelper.parseInteger(context, definition.getMaxPoolSize()));
    answer.setKeepAliveTime(CamelContextHelper.parseLong(context, definition.getKeepAliveTime()));
    answer.setMaxQueueSize(CamelContextHelper.parseInteger(context, definition.getMaxQueueSize()));
    answer.setAllowCoreThreadTimeOut(CamelContextHelper.parseBoolean(context, definition.getAllowCoreThreadTimeOut()));
    answer.setRejectedPolicy(definition.getRejectedPolicy());
    answer.setTimeUnit(definition.getTimeUnit());
    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:AbstractCamelContextFactoryBean.java

示例11: createCustomThreadPool

import org.apache.camel.spi.ThreadPoolProfile; //导入方法依赖的package包/类
private ExecutorService createCustomThreadPool(RouteBuilder builder, String name) {
    ThreadPoolProfile profile = new ThreadPoolProfile();
    profile.setId("I48-custom-profile");
    profile.setPoolSize(50);
    profile.setMaxPoolSize(500);
    profile.setKeepAliveTime(1L);
    profile.setMaxQueueSize(1000);
    profile.setRejectedPolicy(ThreadPoolRejectedPolicy.Abort);
    customPool = builder.getContext().getExecutorServiceManager().newThreadPool(builder, name, profile);
    return customPool;
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:12,代码来源:RouteFactoryTest.java

示例12: createCustomProfile

import org.apache.camel.spi.ThreadPoolProfile; //导入方法依赖的package包/类
public ThreadPoolProfile createCustomProfile() {
    // create a custom thread pool profile with the name bigPool
    ThreadPoolProfile profile = new ThreadPoolProfile("bigPool");
    profile.setMaxPoolSize(200);
    profile.setRejectedPolicy(ThreadPoolRejectedPolicy.DiscardOldest);
    return profile;
}
 
开发者ID:camelinaction,项目名称:camelinaction,代码行数:8,代码来源:CustomThreadPoolProfileTest.java

示例13: createCustomProfile

import org.apache.camel.spi.ThreadPoolProfile; //导入方法依赖的package包/类
public ThreadPoolProfile createCustomProfile() {
    // create a custom thread pool profile with the name bigPool
    ThreadPoolProfile profile = new ThreadPoolProfileSupport("bigPool");
    profile.setMaxPoolSize(200);
    profile.setRejectedPolicy(ThreadPoolRejectedPolicy.DiscardOldest);
    return profile;
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:8,代码来源:CustomThreadPoolProfileTest.java


注:本文中的org.apache.camel.spi.ThreadPoolProfile.setRejectedPolicy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。