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


Java ThreadPoolTaskScheduler.setWaitForTasksToCompleteOnShutdown方法代码示例

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


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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: setDeadlockGuard

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
public void setDeadlockGuard(RTMPConnection conn) {
	ThreadPoolTaskScheduler deadlockGuard = new ThreadPoolTaskScheduler();
	deadlockGuard.setPoolSize(16);
	deadlockGuard.setDaemon(false);
	deadlockGuard.setWaitForTasksToCompleteOnShutdown(true);
	deadlockGuard.setThreadNamePrefix("DeadlockGuardScheduler-");
	deadlockGuard.afterPropertiesSet();
	conn.setDeadlockGuardScheduler(deadlockGuard);
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:10,代码来源:Core.java

示例10: taskScheduler

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Bean(name = "taskScheduler")
public ThreadPoolTaskScheduler taskScheduler() {
    ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
    scheduler.setPoolSize(5);
    scheduler.setWaitForTasksToCompleteOnShutdown(false);

    return scheduler;
}
 
开发者ID:bjornharvold,项目名称:bearchoke,代码行数:9,代码来源:SchedulerConfig.java

示例11: onDestroy

import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; //导入方法依赖的package包/类
@Override
protected void onDestroy() {
    try {
        if (getServletContext().getAttribute("ThreadPoolTaskScheduler") != null) {
            ThreadPoolTaskScheduler executor = (ThreadPoolTaskScheduler) getServletContext()
                    .getAttribute("ThreadPoolTaskScheduler");
            executor.setWaitForTasksToCompleteOnShutdown(false);
            executor.destroy();
        }

        if (getScheduledTaskRegistrar() != null) {
            getScheduledTaskRegistrar().destroy();
        }
        ((BasicDataSource) getBean(DataSource.class)).close();

        EntityManagerFactory entityManagerFactory = getBean(EntityManagerFactory.class);
        if (entityManagerFactory != null) {
            entityManagerFactory.close();
        }

        Enumeration<Driver> drivers = DriverManager.getDrivers();
        Driver d = null;
        while (drivers.hasMoreElements()) {
            try {
                d = drivers.nextElement();
                DriverManager.deregisterDriver(d);
                LOGGER.info("Driver {} deregistered", d);
            } catch (SQLException ex) {
                ex.printStackTrace();
            }
        }

        try {
            Class<?> cls = Class
                    .forName("com.mysql.jdbc.AbandonedConnectionCleanupThread");
            Method mth = (cls == null ? null : cls.getMethod("shutdown"));
            if (mth != null) {
                LOGGER.info("MySQL connection cleanup thread shutdown");
                mth.invoke(null);
                LOGGER.info("MySQL connection cleanup thread shutdown successful");
            }
        } catch (Throwable thr) {
            thr.printStackTrace();
        }

        doDestroy();
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
 
开发者ID:PkayJava,项目名称:pluggable,代码行数:51,代码来源:AbstractWebApplication.java


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