| | |
| | | executor.initialize(); |
| | | return executor; |
| | | } |
| | | |
| | | /** |
| | | * WebSocket推送线程池(避免慢客户端阻塞调度线程) |
| | | * DiscardOldestPolicy: 推送任务允许丢弃旧消息以保证实时性 |
| | | */ |
| | | @Bean("wsPushExecutor") |
| | | public ThreadPoolTaskExecutor wsPushExecutor() { |
| | | ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); |
| | | executor.setCorePoolSize(4); |
| | | executor.setMaxPoolSize(16); |
| | | executor.setQueueCapacity(2000); |
| | | executor.setKeepAliveSeconds(60); |
| | | executor.setThreadNamePrefix("ws-push-"); |
| | | executor.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardOldestPolicy()); |
| | | executor.initialize(); |
| | | return executor; |
| | | } |
| | | } |