package com.vincent.rsf.server.ai.config;
|
|
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Configuration;
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
import java.util.concurrent.Executor;
|
|
@Configuration
|
public class AiAsyncConfig {
|
|
@Bean(name = "aiChatTaskExecutor")
|
public Executor aiChatTaskExecutor() {
|
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
executor.setCorePoolSize(4);
|
executor.setMaxPoolSize(8);
|
executor.setQueueCapacity(100);
|
executor.setThreadNamePrefix("ai-chat-");
|
executor.setWaitForTasksToCompleteOnShutdown(true);
|
executor.setAwaitTerminationSeconds(30);
|
executor.initialize();
|
return executor;
|
}
|
}
|