添加定时任务配置类并记录心跳更新日志

This commit is contained in:
lin 2026-03-30 17:00:11 +08:00
parent 0dc297bf02
commit ede979dbf9
2 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,20 @@
package com.genersoft.iot.vmp.conf;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
@Configuration
public class SchedulingConfig {
@Bean
public TaskScheduler taskScheduler() {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setPoolSize(5);
scheduler.setThreadNamePrefix("scheduled-");
scheduler.setVirtualThreads(true); // 必须在 initialize() 之前
scheduler.initialize();
return scheduler;
}
}

View File

@ -94,6 +94,7 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
}
@Scheduled(fixedDelay = 10, timeUnit = TimeUnit.SECONDS)
public void executeUpdateDeviceList() {
log.info("[定时任务] 更新心跳记录,待处理设备数量: {}", taskQueue.size());
try {
if (!taskQueue.isEmpty()) {
redisCatchStorage.updateDeviceKeepaliveTimeStamp(taskQueue.stream().toList());