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


Java ThreadPoolTaskScheduler.setAwaitTerminationSeconds方法代码示例

本文整理汇总了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;
}
 
开发者ID:chaokunyang,项目名称:amanda,代码行数:20,代码来源:RootContextConfiguration.java

示例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;
}
 
开发者ID:BuaBook,项目名称:buabook-api-interface,代码行数:10,代码来源:BuaBookApiInterfaceConfig.java

示例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;
}
 
开发者ID:shilongdai,项目名称:bookManager,代码行数:24,代码来源:RootApplicationContextConfig.java

示例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;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:8,代码来源:GpfdistSinkConfiguration.java

示例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;
}
 
开发者ID:junbaor,项目名称:telegram-bot,代码行数:10,代码来源:AppConfig.java

示例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;
}
 
开发者ID:sinsengumi,项目名称:spring-boot-application-infrastructure,代码行数:11,代码来源:Application.java

示例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;
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:10,代码来源:ExecutorConfig.java

示例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;
}
 
开发者ID:shilongdai,项目名称:LSChatServer,代码行数:16,代码来源:ApplicationRootContext.java


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