diff --git a/pom.xml b/pom.xml
index c6a626494..7ef99869c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -60,6 +60,7 @@
${project.build.directory}/asciidoc/html
${project.build.directory}/asciidoc/pdf
+ 21
21
21
diff --git a/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java b/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java
index a1d3a527d..f99070f4e 100644
--- a/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java
+++ b/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java
@@ -1,5 +1,6 @@
package com.genersoft.iot.vmp;
+import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.jt1078.util.ClassUtil;
import com.genersoft.iot.vmp.utils.GitUtil;
import com.genersoft.iot.vmp.utils.SpringBeanFactory;
@@ -43,6 +44,7 @@ public class VManageBootstrap extends SpringBootServletInitializer {
log.info("构建时间: {}", gitUtil.getBuildDate());
log.info("GIT信息: 分支: {}, ID: {}, 时间: {}", gitUtil.getBranch(), gitUtil.getCommitIdShort(), gitUtil.getCommitTime());
}
+
}
// 项目重启
public static void restart() {
diff --git a/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java b/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java
index e89695aff..e848d38f4 100644
--- a/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java
+++ b/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java
@@ -19,6 +19,8 @@ public class VideoManagerConstants {
public static final String ONLINE_MEDIA_SERVERS_PREFIX = "VMP_ONLINE_MEDIA_SERVERS:";
public static final String DEVICE_PREFIX = "VMP_DEVICE_INFO";
+ public static final String DEVICE_KEEPALIVE_PREFIX = "VMP_DEVICE_KEEPALIVE:";
+ public static final String DEVICE_REGISTER_PREFIX = "VMP_DEVICE_REGISTER:";
public static final String INVITE_PREFIX = "VMP_GB_INVITE_INFO";
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java b/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java
index 3a1fb917a..44b82488b 100644
--- a/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java
+++ b/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java
@@ -2,11 +2,11 @@ package com.genersoft.iot.vmp.conf;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.stereotype.Component;
-import jakarta.annotation.PostConstruct;
import java.time.Instant;
import java.util.Date;
import java.util.Map;
@@ -23,20 +23,12 @@ import java.util.concurrent.TimeUnit;
@Component
public class DynamicTask {
- private ThreadPoolTaskScheduler threadPoolTaskScheduler;
+ @Autowired
+ private TaskScheduler taskScheduler;
private final Map> futureMap = new ConcurrentHashMap<>();
private final Map runnableMap = new ConcurrentHashMap<>();
- @PostConstruct
- public void DynamicTask() {
- threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
- threadPoolTaskScheduler.setPoolSize(300);
- threadPoolTaskScheduler.setWaitForTasksToCompleteOnShutdown(true);
- threadPoolTaskScheduler.setAwaitTerminationSeconds(10);
- threadPoolTaskScheduler.setThreadNamePrefix("dynamicTask-");
- threadPoolTaskScheduler.initialize();
- }
/**
* 循环执行的任务
@@ -60,7 +52,7 @@ public class DynamicTask {
}
// scheduleWithFixedDelay 必须等待上一个任务结束才开始计时period, cycleForCatalog表示执行的间隔
- future = threadPoolTaskScheduler.scheduleAtFixedRate(task, new Date(System.currentTimeMillis() + cycleForCatalog), cycleForCatalog);
+ future = taskScheduler.scheduleAtFixedRate(task, new Date(System.currentTimeMillis() + cycleForCatalog), cycleForCatalog);
if (future != null){
futureMap.put(key, future);
runnableMap.put(key, task);
@@ -96,7 +88,7 @@ public class DynamicTask {
}
}
// scheduleWithFixedDelay 必须等待上一个任务结束才开始计时period, cycleForCatalog表示执行的间隔
- future = threadPoolTaskScheduler.schedule(task, startInstant);
+ future = taskScheduler.schedule(task, startInstant);
if (future != null){
futureMap.put(key, future);
runnableMap.put(key, task);
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/ScheduleConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/ScheduleConfig.java
deleted file mode 100644
index df88bcf3a..000000000
--- a/src/main/java/com/genersoft/iot/vmp/conf/ScheduleConfig.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.genersoft.iot.vmp.conf;
-
-import org.apache.commons.lang3.concurrent.BasicThreadFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.scheduling.annotation.SchedulingConfigurer;
-import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
-import org.springframework.scheduling.config.ScheduledTaskRegistrar;
-
-import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.ThreadPoolExecutor;
-
-import static com.genersoft.iot.vmp.conf.ThreadPoolTaskConfig.cpuNum;
-
-/**
- * "@Scheduled"是Spring框架提供的一种定时任务执行机制,默认情况下它是单线程的,在同时执行多个定时任务时可能会出现阻塞和性能问题。
- * 为了解决这种单线程瓶颈问题,可以将定时任务的执行机制改为支持多线程
- */
-@Configuration
-public class ScheduleConfig implements SchedulingConfigurer {
-
- /**
- * 核心线程数(默认线程数)
- */
- private static final int corePoolSize = Math.max(cpuNum, 20);
-
- /**
- * 线程池名前缀
- */
- private static final String threadNamePrefix = "schedule";
-
- @Override
- public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
- ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(corePoolSize,
- new BasicThreadFactory.Builder().namingPattern(threadNamePrefix).daemon(true).build(),
- new ThreadPoolExecutor.CallerRunsPolicy());
- taskRegistrar.setScheduler(scheduledThreadPoolExecutor);
- }
-}
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/SchedulingConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/SchedulingConfig.java
new file mode 100644
index 000000000..6896ca63a
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/conf/SchedulingConfig.java
@@ -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;
+ }
+}
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/SystemInfoTimerTask.java b/src/main/java/com/genersoft/iot/vmp/conf/SystemInfoTimerTask.java
index 0c6eb2359..581fd5694 100644
--- a/src/main/java/com/genersoft/iot/vmp/conf/SystemInfoTimerTask.java
+++ b/src/main/java/com/genersoft/iot/vmp/conf/SystemInfoTimerTask.java
@@ -20,22 +20,22 @@ public class SystemInfoTimerTask {
@Autowired
private IRedisCatchStorage redisCatchStorage;
- @Scheduled(fixedRate = 2000) //每1秒执行一次
- public void execute(){
- try {
- double cpuInfo = SystemInfoUtils.getCpuInfo();
- redisCatchStorage.addCpuInfo(cpuInfo);
- double memInfo = SystemInfoUtils.getMemInfo();
- redisCatchStorage.addMemInfo(memInfo);
- Map networkInterfaces = SystemInfoUtils.getNetworkInterfaces();
- redisCatchStorage.addNetInfo(networkInterfaces);
- List