update 桩端连接相关内容,解决频繁登录

This commit is contained in:
Lemon
2026-03-21 10:19:22 +08:00
parent c9d7f505b6
commit c10ac24323
6 changed files with 278 additions and 42 deletions

View File

@@ -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创建成功");