将ragflow参数写道配置文件

This commit is contained in:
wuchunlei
2025-05-12 13:10:50 +08:00
parent 8f0ef33d52
commit 1ba1c6a418
5 changed files with 197 additions and 123 deletions

View File

@@ -2,11 +2,13 @@ package com.peanut.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
@Configuration
@EnableAsync
@@ -21,4 +23,18 @@ public class AsyncConfig implements AsyncConfigurer {
executor.initialize();
return executor;
}
@Bean("fluxTaskExecutor")
public AsyncTaskExecutor fluxTaskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(Runtime.getRuntime().availableProcessors() * 2); // CPU密集型建议值
executor.setMaxPoolSize(50);
executor.setQueueCapacity(100);
executor.setThreadNamePrefix("flux-exec-");
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
executor.initialize();
return executor;
}
}