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


Java ThreadPoolTaskScheduler.setPoolSize方法代码示例

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


在下文中一共展示了ThreadPoolTaskScheduler.setPoolSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: taskScheduler

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Bean
public ThreadPoolTaskScheduler taskScheduler()
{
    logger.info("Setting up thread pool task scheduler with 20 threads.");
    ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
    scheduler.setPoolSize(20);
    scheduler.setThreadNamePrefix("task-");
    scheduler.setAwaitTerminationSeconds(60);
    scheduler.setWaitForTasksToCompleteOnShutdown(true);
    scheduler.setErrorHandler(t -> schedulingLogger.error(
            "Unknown error occurred while executing task.", t
    ));
    scheduler.setRejectedExecutionHandler(
            (r, e) -> schedulingLogger.error(
                    "Execution of task {} was rejected for unknown reasons.", r
            )
    );
    return scheduler;
}
 
开发者ID:chaokunyang,项目名称:amanda,代码行数:20,代码来源:RootContextConfiguration.java

示例2: taskScheduler

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Bean
public ThreadPoolTaskScheduler taskScheduler() {
	String levelString = context.getInitParameter("threadNumber");
	if (levelString == null) {
		levelString = "4";
	}
	int level = Integer.parseInt(levelString);
	log.info("Creating thread pool with " + level + " threads");
	ThreadPoolTaskScheduler exec = new ThreadPoolTaskScheduler();
	exec.setPoolSize(level);
	exec.setThreadNamePrefix("transaction");
	exec.setAwaitTerminationSeconds(60);
	exec.setWaitForTasksToCompleteOnShutdown(true);
	exec.setRejectedExecutionHandler(new RejectedExecutionHandler() {

		@Override
		public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
			StringBuilder errorBuilder = new StringBuilder("Task Rejected");
			log.error(errorBuilder.toString());
		}
	});
	return exec;
}
 
开发者ID:shilongdai,项目名称:bookManager,代码行数:24,代码来源:RootApplicationContextConfig.java

示例3: vaultTaskScheduler

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
/**
 * Creates a new {@link TaskSchedulerWrapper} that encapsulates a bean implementing
 * {@link TaskScheduler} and {@link AsyncTaskExecutor}.
 *
 * @return
 * @see ThreadPoolTaskScheduler
 */
@Bean
@Lazy
@ConditionalOnMissingBean(TaskSchedulerWrapper.class)
public TaskSchedulerWrapper vaultTaskScheduler() {

	ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
	threadPoolTaskScheduler.setPoolSize(2);
	threadPoolTaskScheduler.setDaemon(true);
	threadPoolTaskScheduler.setThreadNamePrefix("Spring-Cloud-Vault-");

	// This is to destroy bootstrap resources
	// otherwise, the bootstrap context is not shut down cleanly
	applicationContext.registerShutdownHook();

	return new TaskSchedulerWrapper(threadPoolTaskScheduler);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-vault,代码行数:24,代码来源:VaultBootstrapConfiguration.java

示例4: initBackgroundJobs

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
protected void initBackgroundJobs(WebApplicationContext ctx) {
    try {
        IConfigurationService configurationService = ctx.getBean(IConfigurationService.class);
        IImportExportService importExportService = ctx.getBean(IImportExportService.class);
        IOperationsService operationsService = ctx.getBean(IOperationsService.class);
        
        jobScheduler = new ThreadPoolTaskScheduler();
        jobScheduler.setDaemon(true);
        jobScheduler.setThreadNamePrefix("background-job-");
        jobScheduler.setPoolSize(2);
        jobScheduler.initialize();

        TypedProperties properties = operationsService.findGlobalSetttingsAsProperties();
        if (properties.is(CONFIG_BACKUP_ENABLED, DEFAULT_CONFIG_BACKUP_ENABLED)) {
            jobScheduler.schedule(new BackupJob(importExportService, configurationService, operationsService, getConfigDir(false)),
                    new CronTrigger(
                            properties.get(CONFIG_BACKUP_CRON, DEFAULT_CONFIG_BACKUP_CRON)));
        }
        jobScheduler.scheduleAtFixedRate(() -> configurationService.doInBackground(), 600000);
    } catch (Exception e) {
        LoggerFactory.getLogger(getClass()).info("Failed to schedule  the backup job", e);
    }
}
 
开发者ID:JumpMind,项目名称:metl,代码行数:24,代码来源:AppInitializer.java

示例5: taskScheduler

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Bean()
public ThreadPoolTaskScheduler taskScheduler() {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setPoolSize(100);
scheduler.setThreadNamePrefix("Scheduler-");
scheduler.setWaitForTasksToCompleteOnShutdown(true);
scheduler.setRemoveOnCancelPolicy(true);
   return scheduler;
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:10,代码来源:SpringScheduledConfig.java

示例6: configureTasks

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
    taskScheduler.setPoolSize(50);
    taskScheduler.initialize();
    taskRegistrar.setTaskScheduler(taskScheduler);
}
 
开发者ID:modum-io,项目名称:tokenapp-backend,代码行数:8,代码来源:SchedulingConfigurerConfiguration.java

示例7: configureTasks

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Override
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
    ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();

    threadPoolTaskScheduler.setPoolSize(POOL_SIZE);
    threadPoolTaskScheduler.setThreadNamePrefix("SchedulerThreads-");
    threadPoolTaskScheduler.initialize();

    scheduledTaskRegistrar.setTaskScheduler(threadPoolTaskScheduler);
}
 
开发者ID:italia,项目名称:daf-replicate-ingestion,代码行数:11,代码来源:SchedulerConfig.java

示例8: taskScheduler

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Bean
public TaskScheduler taskScheduler () {
	ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
	scheduler.setThreadNamePrefix( CsapCoreService.class.getSimpleName() + "Scheduler" );
	scheduler.setPoolSize( 2 );
	return scheduler;
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:8,代码来源:CsapCoreService.java

示例9: batchTaskScheduler

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Bean
public ThreadPoolTaskScheduler batchTaskScheduler() {
	ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
	threadPoolTaskScheduler.setPoolSize(10);
	threadPoolTaskScheduler.afterPropertiesSet();
	return threadPoolTaskScheduler;
}
 
开发者ID:namics,项目名称:spring-batch-support,代码行数:8,代码来源:TaskExecutorBatchConfigurer.java

示例10: taskSchedulerExecutor

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Bean(name = "taskSchedulerExecutor")
public ThreadPoolTaskScheduler taskSchedulerExecutor() {
    ThreadPoolTaskScheduler threadPool = new ThreadPoolTaskScheduler();
    threadPool.setPoolSize(80);
    threadPool.setRejectedExecutionHandler(new RejectExecutionImpl());
    threadPool.setThreadNamePrefix("Scheduler-");
    threadPool.setThreadGroupName("Scheduler");
    return threadPool;
}
 
开发者ID:farchanjo,项目名称:webcron,代码行数:10,代码来源:ExecutorConfig.java

示例11: schedulerTaskExecutor

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
/**
 * Thread pool for spring scheduling
 */
@Bean(destroyMethod = "shutdown")
public ThreadPoolTaskScheduler schedulerTaskExecutor() {
    ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
    scheduler.setPoolSize(DEFAULT_SCHEDULER_POOL_SIZE);
    scheduler.setDaemon(true);
    scheduler.setThreadNamePrefix("api-task-");
    scheduler.initialize();
    return scheduler;
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:13,代码来源:SchedulerConfig.java

示例12: taskScheduler

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Bean(destroyMethod = "shutdown")
public ThreadPoolTaskScheduler taskScheduler() {
    ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
    scheduler.setPoolSize(20);
    scheduler.setThreadNamePrefix("task-");
    scheduler.setAwaitTerminationSeconds(60);
    scheduler.setWaitForTasksToCompleteOnShutdown(true);
    return scheduler;
}
 
开发者ID:junbaor,项目名称:telegram-bot,代码行数:10,代码来源:AppConfig.java

示例13: configureTasks

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
    taskScheduler.setThreadNamePrefix("task-pool");
    taskScheduler.setPoolSize(10);
    taskScheduler.initialize();
    taskRegistrar.setTaskScheduler(taskScheduler);
}
 
开发者ID:gessnerfl,项目名称:fake-smtp-server,代码行数:9,代码来源:SchedulingConfig.java

示例14: configureTasks

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
    taskScheduler.setPoolSize(5);
    taskScheduler.initialize();
    taskScheduler.setThreadNamePrefix("ScheduledExecutor-");

    taskRegistrar.setTaskScheduler(taskScheduler);
}
 
开发者ID:ruslanys,项目名称:vkmusic,代码行数:10,代码来源:ExecutorsConfig.java

示例15: getAsyncExecutor

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Override
public Executor getAsyncExecutor() {
    ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
    scheduler.setPoolSize(10);
    scheduler.initialize();
    return scheduler;
}
 
开发者ID:borysfan,项目名称:websocket-poc,代码行数:8,代码来源:AyncConfiguration.java


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