| 30374 |
amit.gupta |
1 |
package com.smartdukaan.cron.config;
|
|
|
2 |
|
|
|
3 |
import org.springframework.context.annotation.Configuration;
|
|
|
4 |
import org.springframework.scheduling.annotation.SchedulingConfigurer;
|
|
|
5 |
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
|
|
6 |
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
|
|
7 |
|
|
|
8 |
@Configuration
|
|
|
9 |
public class SchedulerConfig implements SchedulingConfigurer {
|
|
|
10 |
/**
|
|
|
11 |
* The pool size.
|
|
|
12 |
*/
|
|
|
13 |
private final int POOL_SIZE = 10;
|
|
|
14 |
|
|
|
15 |
/**
|
|
|
16 |
* Configures the scheduler to allow multiple pools.
|
|
|
17 |
*
|
|
|
18 |
* @param taskRegistrar The task registrar.
|
|
|
19 |
*/
|
|
|
20 |
@Override
|
|
|
21 |
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
|
|
|
22 |
ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
|
|
|
23 |
|
|
|
24 |
threadPoolTaskScheduler.setPoolSize(POOL_SIZE);
|
|
|
25 |
threadPoolTaskScheduler.setThreadNamePrefix("scheduled-task-pool-");
|
|
|
26 |
threadPoolTaskScheduler.initialize();
|
|
|
27 |
|
|
|
28 |
taskRegistrar.setTaskScheduler(threadPoolTaskScheduler);
|
|
|
29 |
}
|
|
|
30 |
}
|