BAEL-5247: Add TaskScheduler config example (#11626)
This commit is contained in:
parent
3b687e3fed
commit
525b7b913a
|
@ -5,7 +5,9 @@ import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.PropertySource;
|
import org.springframework.context.annotation.PropertySource;
|
||||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||||
|
import org.springframework.scheduling.TaskScheduler;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
|
@ -13,6 +15,14 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
@PropertySource("classpath:springScheduled.properties")
|
@PropertySource("classpath:springScheduled.properties")
|
||||||
public class SpringSchedulingConfig {
|
public class SpringSchedulingConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public TaskScheduler taskScheduler() {
|
||||||
|
ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
|
||||||
|
threadPoolTaskScheduler.setPoolSize(5);
|
||||||
|
threadPoolTaskScheduler.setThreadNamePrefix("ThreadPoolTaskScheduler");
|
||||||
|
return threadPoolTaskScheduler;
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
|
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
|
||||||
return new PropertySourcesPlaceholderConfigurer();
|
return new PropertySourcesPlaceholderConfigurer();
|
||||||
|
|
Loading…
Reference in New Issue