Java Code Examples for org.springframework.scheduling.config.ScheduledTaskRegistrar#setTaskScheduler()

The following examples show how to use org.springframework.scheduling.config.ScheduledTaskRegistrar#setTaskScheduler() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SchedulingConfigurerConfiguration.java    From tutorial with MIT License 5 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    if (log.isTraceEnabled()) {
        log.trace("configure scheduling tasks.");
    }
    ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
    taskScheduler.setPoolSize(10); // 设置有多少线程负责执行定时任务,默认只有1个。
    taskScheduler.initialize();
    taskRegistrar.setTaskScheduler(taskScheduler);
}
 
Example 2
Source File: SchedulerConfig.java    From springboot-guide with Apache License 2.0 5 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
    ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();

    threadPoolTaskScheduler.setPoolSize(POOL_SIZE);
    threadPoolTaskScheduler.setThreadNamePrefix("my-scheduled-task-pool-");
    threadPoolTaskScheduler.initialize();

    scheduledTaskRegistrar.setTaskScheduler(threadPoolTaskScheduler);
}
 
Example 3
Source File: SchedulerConfig.java    From Pixiv-Illustration-Collection-Backend with Apache License 2.0 5 votes vote down vote up
/**
 * Configures the scheduler to allow multiple pools.
 *
 * @param taskRegistrar The task registrar.
 */
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();

    threadPoolTaskScheduler.setPoolSize(POOL_SIZE);
    threadPoolTaskScheduler.setThreadNamePrefix("scheduled-task-pool-");
    threadPoolTaskScheduler.initialize();

    taskRegistrar.setTaskScheduler(threadPoolTaskScheduler);
}
 
Example 4
Source File: SchedulerConfig.java    From code-examples with MIT License 5 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();

    scheduler.setPoolSize(POOL_SIZE);
    scheduler.setThreadNamePrefix("My-Scheduler-");
    scheduler.initialize();

    taskRegistrar.setTaskScheduler(scheduler);
}
 
Example 5
Source File: SchedulingConfig.java    From fake-smtp-server with Apache License 2.0 5 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    var taskScheduler = new ThreadPoolTaskScheduler();
    taskScheduler.setThreadNamePrefix("task-pool");
    taskScheduler.setPoolSize(10);
    taskScheduler.initialize();
    taskRegistrar.setTaskScheduler(taskScheduler);
}
 
Example 6
Source File: ScheduledConfig.java    From plumdo-work with Apache License 2.0 4 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar registrar) {
    registrar.setTaskScheduler(taskScheduler());
}
 
Example 7
Source File: Spring4WebSocketExamplesApplication.java    From spring4ws-demos with Apache License 2.0 4 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
	taskRegistrar.setTaskScheduler(new ConcurrentTaskScheduler(
			Executors.newSingleThreadScheduledExecutor()));
}
 
Example 8
Source File: Application.java    From boot-examples with Apache License 2.0 4 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    taskRegistrar.setTaskScheduler(reservationPool());
}
 
Example 9
Source File: ScheduleConfig.java    From cloudbreak with Apache License 2.0 4 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    taskRegistrar.setTaskScheduler(taskScheduler());
}
 
Example 10
Source File: SchedulerConfig.java    From bearchoke with Apache License 2.0 4 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar registrar) {
    registrar.setTaskScheduler(taskScheduler());
}
 
Example 11
Source File: SchedulingConfig.java    From botanic-ng with Apache License 2.0 4 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
	taskRegistrar.setTaskScheduler(taskScheduler());
}
 
Example 12
Source File: WebSocketConfig.java    From myfeed with Apache License 2.0 4 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
	taskRegistrar.setTaskScheduler(taskScheduler);
}
 
Example 13
Source File: DIConfiguration.java    From waltz with Apache License 2.0 4 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
    scheduledTaskRegistrar.setTaskScheduler(taskScheduler());
}
 
Example 14
Source File: BootStrap.java    From MyBlog with Apache License 2.0 4 votes vote down vote up
/*********************************************************************************************************/
//SchedulingConfigurer 设置定时任务线程池
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    taskRegistrar.setTaskScheduler(scheduledExecutor());
}
 
Example 15
Source File: SpringScheduledConfig.java    From Spring-5.0-Cookbook with MIT License 4 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
	taskRegistrar.setTaskScheduler(taskScheduler());
	
}
 
Example 16
Source File: ScheduleConfig.java    From Alice-LiveMan with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    TaskScheduler taskScheduler = taskScheduler();
    taskRegistrar.setTaskScheduler(taskScheduler);
}
 
Example 17
Source File: SchedulingConfiguration.java    From dk-foundation with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void configureTasks(ScheduledTaskRegistrar scheduledTaskRegistrar) {
    scheduledTaskRegistrar.setTaskScheduler(taskScheduler());
}
 
Example 18
Source File: ScheduledThreadPoolConfig.java    From hdw-dubbo with Apache License 2.0 2 votes vote down vote up
/**
 * 对于CPU密集型任务,最大线程数是CPU线程数+1。对于IO密集型任务,尽量多配点,可以是CPU线程数*2,或者CPU线程数/(1-阻塞系数)。
 * maxPoolSize=new Double(Math.floor(Runtime.getRuntime().availableProcessors()/(1-0.9))).intValue()
 *
 * @param taskRegistrar
 */

@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
    taskRegistrar.setTaskScheduler(taskScheduler());
}