尝试修复catalog获取失败。服务重启后设备未注册仍上报keeplive处理

This commit is contained in:
songww
2020-05-13 14:55:06 +08:00
parent d072017bdc
commit ca5139929b
11 changed files with 145 additions and 48 deletions

View File

@@ -0,0 +1,24 @@
package com.genersoft.iot.vmp.gb28181.event;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
/**
* @Description:设备离在线状态检测器,用于检测设备状态
* @author: songww
* @date: 2020年5月13日 下午2:40:29
*/
@Component
public class DeviceOffLineDetector {
@Autowired
private RedisUtil redis;
public boolean isOnline(String deviceId) {
String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + deviceId;
return redis.hasKey(key);
}
}

View File

@@ -4,8 +4,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;
import com.genersoft.iot.vmp.gb28181.event.offline.OfflineEvent;
import com.genersoft.iot.vmp.gb28181.event.online.OnlineEvent;
import com.genersoft.iot.vmp.gb28181.event.outline.OutlineEvent;
/**
* @Description:Event事件通知推送器支持推送在线事件、离线事件
@@ -26,7 +26,7 @@ public class EventPublisher {
}
public void outlineEventPublish(String deviceId, String from){
OutlineEvent outEvent = new OutlineEvent(this);
OfflineEvent outEvent = new OfflineEvent(this);
outEvent.setDeviceId(deviceId);
outEvent.setFrom(from);
applicationEventPublisher.publishEvent(outEvent);

View File

@@ -1,4 +1,4 @@
package com.genersoft.iot.vmp.gb28181.event.outline;
package com.genersoft.iot.vmp.gb28181.event.offline;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.Message;

View File

@@ -1,4 +1,4 @@
package com.genersoft.iot.vmp.gb28181.event.outline;
package com.genersoft.iot.vmp.gb28181.event.offline;
import org.springframework.context.ApplicationEvent;
@@ -7,7 +7,7 @@ import org.springframework.context.ApplicationEvent;
* @author: songww
* @date: 2020年5月6日 上午11:33:13
*/
public class OutlineEvent extends ApplicationEvent {
public class OfflineEvent extends ApplicationEvent {
/**
* @Title: OutlineEvent
@@ -15,7 +15,7 @@ public class OutlineEvent extends ApplicationEvent {
* @param: @param source
* @throws
*/
public OutlineEvent(Object source) {
public OfflineEvent(Object source) {
super(source);
}

View File

@@ -1,4 +1,4 @@
package com.genersoft.iot.vmp.gb28181.event.outline;
package com.genersoft.iot.vmp.gb28181.event.offline;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -13,14 +13,14 @@ import com.genersoft.iot.vmp.utils.redis.RedisUtil;
/**
* @Description: 离线事件监听器监听到离线后修改设备离在线状态 设备离线有两个来源
* 1设备主动注销发送注销指令{@link com.genersoft.iot.vmp.gb28181.transmit.request.impl.RegisterRequestProcessor}
* 2设备未知原因离线心跳超时,{@link com.genersoft.iot.vmp.gb28181.event.outline.OutlineEventListener}
* 2设备未知原因离线心跳超时,{@link com.genersoft.iot.vmp.gb28181.event.offline.OfflineEventListener}
* @author: songww
* @date: 2020年5月6日 下午1:51:23
*/
@Component
public class OutlineEventListener implements ApplicationListener<OutlineEvent> {
public class OfflineEventListener implements ApplicationListener<OfflineEvent> {
private final static Logger logger = LoggerFactory.getLogger(OutlineEventListener.class);
private final static Logger logger = LoggerFactory.getLogger(OfflineEventListener.class);
@Autowired
private IVideoManagerStorager storager;
@@ -29,7 +29,7 @@ public class OutlineEventListener implements ApplicationListener<OutlineEvent> {
private RedisUtil redis;
@Override
public void onApplicationEvent(OutlineEvent event) {
public void onApplicationEvent(OfflineEvent event) {
if (logger.isDebugEnabled()) {
logger.debug("设备离线事件触发deviceId" + event.getDeviceId() + ",from:" + event.getFrom());