11package com .edunexus .api .config ;
22
33import java .net .URI ;
4- import java .util .concurrent .ThreadPoolExecutor ;
54import org .springframework .beans .factory .annotation .Value ;
65import org .springframework .context .annotation .Bean ;
76import org .springframework .context .annotation .Configuration ;
7+ import org .springframework .core .task .SimpleAsyncTaskExecutor ;
88import org .springframework .core .task .TaskExecutor ;
9- import org .springframework .scheduling .concurrent .ThreadPoolTaskExecutor ;
109import org .springframework .security .crypto .bcrypt .BCryptPasswordEncoder ;
1110import org .springframework .security .crypto .password .PasswordEncoder ;
1211import org .springframework .web .servlet .config .annotation .CorsRegistry ;
@@ -26,29 +25,15 @@ public PasswordEncoder passwordEncoder() {
2625
2726 @ Bean (name = "documentIngestExecutor" )
2827 public TaskExecutor documentIngestExecutor () {
29- ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor ();
30- executor .setCorePoolSize (2 );
31- executor .setMaxPoolSize (4 );
32- executor .setQueueCapacity (100 );
33- executor .setThreadNamePrefix ("doc-ingest-" );
34- executor .setRejectedExecutionHandler (new ThreadPoolExecutor .CallerRunsPolicy ());
35- executor .setWaitForTasksToCompleteOnShutdown (true );
36- executor .setAwaitTerminationSeconds (30 );
37- executor .initialize ();
28+ SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor ("doc-ingest-" );
29+ executor .setVirtualThreads (true );
3830 return executor ;
3931 }
4032
4133 @ Bean (name = "chatStreamExecutor" )
4234 public TaskExecutor chatStreamExecutor () {
43- ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor ();
44- executor .setCorePoolSize (4 );
45- executor .setMaxPoolSize (8 );
46- executor .setQueueCapacity (200 );
47- executor .setThreadNamePrefix ("chat-stream-" );
48- executor .setRejectedExecutionHandler (new ThreadPoolExecutor .CallerRunsPolicy ());
49- executor .setWaitForTasksToCompleteOnShutdown (true );
50- executor .setAwaitTerminationSeconds (15 );
51- executor .initialize ();
35+ SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor ("chat-stream-" );
36+ executor .setVirtualThreads (true );
5237 return executor ;
5338 }
5439
@@ -63,7 +48,7 @@ public void addCorsMappings(CorsRegistry registry) {
6348 .allowedOriginPatterns (allowedOriginPatterns )
6449 .allowedMethods ("GET" , "POST" , "PUT" , "PATCH" , "DELETE" , "OPTIONS" )
6550 .allowedHeaders ("*" )
66- .exposedHeaders ("X-Request-Id" );
51+ .exposedHeaders ("X-Request-Id" , "X-Trace-Id" );
6752 }
6853 };
6954 }
0 commit comments