66import org .springframework .scheduling .concurrent .ThreadPoolTaskExecutor ;
77
88import java .util .concurrent .Executor ;
9+ import java .util .concurrent .ThreadPoolExecutor ;
910
1011@ Configuration
1112@ EnableAsync
@@ -14,9 +15,9 @@ public class AsyncConfig {
1415 @ Bean (name = "taskExecutor" )
1516 public Executor taskExecutor () {
1617 ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor ();
17- executor .setCorePoolSize (20 ); // 기본 스레드 수
18- executor .setMaxPoolSize (100 ); // 최대 스레드 수
19- executor .setQueueCapacity (1000 ); // 대기 큐 크기
18+ executor .setCorePoolSize (20 );
19+ executor .setMaxPoolSize (100 );
20+ executor .setQueueCapacity (1000 );
2021 executor .setThreadNamePrefix ("SSE-Async-" );
2122 executor .initialize ();
2223 return executor ;
@@ -25,10 +26,14 @@ public Executor taskExecutor() {
2526 @ Bean (name = "alertExecutor" )
2627 public Executor alertExecutor () {
2728 ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor ();
28- executor .setCorePoolSize (20 );
29- executor .setMaxPoolSize (50 );
30- executor .setQueueCapacity (500 );
29+ executor .setCorePoolSize (50 ); // 20 → 50 증가
30+ executor .setMaxPoolSize (100 ); // 50 → 100 증가
31+ executor .setQueueCapacity (2000 ); // 500 → 2000 증가
3132 executor .setThreadNamePrefix ("Alert-" );
33+
34+ // ✅ 큐 포화 시 호출 스레드에서 실행 (거부 방지)
35+ executor .setRejectedExecutionHandler (new ThreadPoolExecutor .CallerRunsPolicy ());
36+
3237 executor .setWaitForTasksToCompleteOnShutdown (true );
3338 executor .setAwaitTerminationSeconds (60 );
3439 executor .initialize ();
0 commit comments