forked from Thirdparty/wvp
1
0
Fork 0
yunnan-road
axzsd 2023-10-20 14:59:04 +08:00
parent 3b68a00018
commit 090b31f678
2 changed files with 23 additions and 13 deletions

View File

@ -41,6 +41,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>

View File

@ -1,5 +1,7 @@
package com.genersoft.iot.vmp.gb28181.event.offline;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
@ -9,23 +11,25 @@ import org.springframework.stereotype.Component;
import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
/**
/**
* @Description:,redis线
* @author: swwheihei
* @date: 202056 11:35:46
* @date: 202056 11:35:46
*/
@Component
public class KeepliveTimeoutListener extends KeyExpirationEventMessageListener {
@Autowired
private EventPublisher publisher;
@Autowired
private EventPublisher publisher;
private static final Logger log = LoggerFactory.getLogger(KeepliveTimeoutListener.class);
public KeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer) {
super(listenerContainer);
}
public KeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer) {
super(listenerContainer);
}
/**
/**
* keykeykeeplive_deviceId
*
* @param message
* @param pattern
*/
@ -33,12 +37,14 @@ public class KeepliveTimeoutListener extends KeyExpirationEventMessageListener {
public void onMessage(Message message, byte[] pattern) {
// 获取失效的key
String expiredKey = message.toString();
if(!expiredKey.startsWith(VideoManagerConstants.KEEPLIVEKEY_PREFIX)){
System.out.println("收到redis过期监听但开头不是"+VideoManagerConstants.KEEPLIVEKEY_PREFIX+",忽略");
return;
if (!expiredKey.startsWith(VideoManagerConstants.KEEPLIVEKEY_PREFIX)) {
if (log.isDebugEnabled()) {
log.debug("收到redis过期监听但开头不是" + VideoManagerConstants.KEEPLIVEKEY_PREFIX + ",忽略");
}
return;
}
String deviceId = expiredKey.substring(VideoManagerConstants.KEEPLIVEKEY_PREFIX.length(),expiredKey.length());
String deviceId = expiredKey.substring(VideoManagerConstants.KEEPLIVEKEY_PREFIX.length(), expiredKey.length());
publisher.outlineEventPublish(deviceId, VideoManagerConstants.EVENT_OUTLINE_TIMEOUT);
}
}