本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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);
}
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例9: batchTaskScheduler
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Bean
public ThreadPoolTaskScheduler batchTaskScheduler() {
ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
threadPoolTaskScheduler.setPoolSize(10);
threadPoolTaskScheduler.afterPropertiesSet();
return threadPoolTaskScheduler;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例15: getAsyncExecutor
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Override
public Executor getAsyncExecutor() {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setPoolSize(10);
scheduler.initialize();
return scheduler;
}