本文整理汇总了Java中org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler.setAwaitTerminationSeconds方法的典型用法代码示例。如果您正苦于以下问题:Java ThreadPoolTaskScheduler.setAwaitTerminationSeconds方法的具体用法?Java ThreadPoolTaskScheduler.setAwaitTerminationSeconds怎么用?Java ThreadPoolTaskScheduler.setAwaitTerminationSeconds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler
的用法示例。
在下文中一共展示了ThreadPoolTaskScheduler.setAwaitTerminationSeconds方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: bbTaskScheduler
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Bean
public TaskScheduler bbTaskScheduler() {
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
taskScheduler.setThreadNamePrefix("API-Schd-ThrP-");
taskScheduler.setAwaitTerminationSeconds(1);
taskScheduler.setRejectedExecutionHandler(new ThreadPoolTaskRejectedHandler());
return taskScheduler;
}
示例3: 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;
}
示例4: sqlTaskScheduler
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Bean
public TaskScheduler sqlTaskScheduler() {
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
taskScheduler.setWaitForTasksToCompleteOnShutdown(true);
taskScheduler.setAwaitTerminationSeconds(properties.getBatchTimeout());
return taskScheduler;
}
示例5: 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;
}
示例6: taskScheduler
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Bean(destroyMethod = "shutdown")
public Executor taskScheduler() {
ThreadPoolTaskScheduler threadPool = new ThreadPoolTaskScheduler();
threadPool.setPoolSize(5);
// shutdown 時に Task の完了を待つ(最大10分間)
threadPool.setWaitForTasksToCompleteOnShutdown(true);
threadPool.setAwaitTerminationSeconds(60 * 10);
return threadPool;
}
示例7: commonTaskScheduler
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Bean
public ThreadPoolTaskScheduler commonTaskScheduler() {
final ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setPoolSize(20);
scheduler.setWaitForTasksToCompleteOnShutdown(true);
scheduler.setAwaitTerminationSeconds(30);
return scheduler;
}
示例8: taskScheduler
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Bean
public ThreadPoolTaskScheduler taskScheduler() {
int level = 2;
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((Runnable r, ThreadPoolExecutor executor) -> {
String errorBuilder = "Task Rejected";
log.error(errorBuilder);
});
return exec;
}