mirror of
https://gitee.com/pan648540858/wvp-GB28181-pro.git
synced 2026-05-22 21:37:48 +08:00
添加定时任务配置类并记录心跳更新日志
This commit is contained in:
parent
0dc297bf02
commit
ede979dbf9
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -94,6 +94,7 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp
|
|||||||
}
|
}
|
||||||
@Scheduled(fixedDelay = 10, timeUnit = TimeUnit.SECONDS)
|
@Scheduled(fixedDelay = 10, timeUnit = TimeUnit.SECONDS)
|
||||||
public void executeUpdateDeviceList() {
|
public void executeUpdateDeviceList() {
|
||||||
|
log.info("[定时任务] 更新心跳记录,待处理设备数量: {}", taskQueue.size());
|
||||||
try {
|
try {
|
||||||
if (!taskQueue.isEmpty()) {
|
if (!taskQueue.isEmpty()) {
|
||||||
redisCatchStorage.updateDeviceKeepaliveTimeStamp(taskQueue.stream().toList());
|
redisCatchStorage.updateDeviceKeepaliveTimeStamp(taskQueue.stream().toList());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user