반응형
프로퍼티 설정
my.task.core.poolsize=10
my.task.capacity=50
my.task.max.poolsize=20
my.scheduler.poolsize=20
설정 클래스
@Configuration
@EnableAsync
public class MyBean{
@Bean
@ConfitureationProperties(prefix="my.task")
public Executor taskExecutor() {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
/* 코드상에 명시적으로 설정 하려면 아래 주석 처리 부분을 사용 */
//taskExecutor.setCorePoolSize(10);
//taskExecutor.setQueueCapacity(50);
//taskExecutor.setMaxPoolSize(20);
return taskExecutor;
}
@Bean
@ConfigurationProperties(prefix = "my.scheduler")
public TaskScheduler taskScheduler() {
return new ConcurrentTaskScheduler();
}
}
public class MyAsync{
@Async
public void asyncWorker(){
//code here
}
@Scheduled(cron="* * * 1 * *")
public void scheduleWorker(){
}
}
반응형
'SpringBoot' 카테고리의 다른 글
spring security - ip based url pattern access (0) | 2018.07.18 |
---|---|
Swagger default httpstatus code 200 disable (0) | 2018.05.28 |
Springboot jar execute script (1) | 2018.05.15 |
Intellij kotlin var inspection disable (0) | 2018.04.19 |
Java enum and toString() 구현 (0) | 2018.04.10 |