本文整理汇总了Java中org.apache.camel.spi.ThreadPoolProfile.setTimeUnit方法的典型用法代码示例。如果您正苦于以下问题:Java ThreadPoolProfile.setTimeUnit方法的具体用法?Java ThreadPoolProfile.setTimeUnit怎么用?Java ThreadPoolProfile.setTimeUnit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.camel.spi.ThreadPoolProfile
的用法示例。
在下文中一共展示了ThreadPoolProfile.setTimeUnit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
示例4: 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;
}