mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
update 桩端连接相关内容,解决频繁登录
This commit is contained in:
@@ -27,8 +27,8 @@ public class ThreadPoolConfig {
|
||||
// 最大可创建的线程数
|
||||
private final int maxPoolSize = 128; // 突发时翻倍,避免过多上下文切换
|
||||
|
||||
// 队列最大长度
|
||||
private final int queueCapacity = 2000; // 桩消息短时堆积时提供缓冲,防止直接拒绝
|
||||
// 队列最大长度 (优化:增大队列容量以应对桩端消息高峰)
|
||||
private final int queueCapacity = 5000; // 桩消息短时堆积时提供缓冲,防止直接拒绝
|
||||
|
||||
// 线程池维护线程所允许的空闲时间
|
||||
private final int keepAliveSeconds = 120; // 突发结束后快速回收扩展线程
|
||||
@@ -51,6 +51,7 @@ public class ThreadPoolConfig {
|
||||
|
||||
/**
|
||||
* 线程池
|
||||
* 优化:使用 DiscardOldestPolicy 避免阻塞调用者线程(如 Netty IO 线程)
|
||||
*/
|
||||
@Bean(name = "threadPoolTaskExecutor")
|
||||
public ThreadPoolTaskExecutor threadPoolTaskExecutor() {
|
||||
@@ -60,7 +61,8 @@ public class ThreadPoolConfig {
|
||||
executor.setQueueCapacity(queueCapacity);
|
||||
executor.setKeepAliveSeconds(keepAliveSeconds);
|
||||
// 线程池对拒绝任务(无线程可用)的处理策略
|
||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
// 优化:DiscardOldestPolicy 丢弃最老的任务,避免阻塞调用者线程
|
||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardOldestPolicy());
|
||||
executor.setThreadNamePrefix(threadNamePrefix);
|
||||
executor.setWaitForTasksToCompleteOnShutdown(true);
|
||||
// log.info("threadPoolTaskExecutor创建成功");
|
||||
|
||||
Reference in New Issue
Block a user