From e21e419361ca69c31c8eed7349ce4d44ca42313a Mon Sep 17 00:00:00 2001
From: canghai809 <lovecanghai@gmail.com>
Date: 星期二, 04 四月 2023 18:52:13 +0800
Subject: [PATCH] 开发及Docker配置文件数据源更新
---
src/main/java/com/genersoft/iot/vmp/conf/redis/RedisConfig.java | 66 ++++----------------------------
1 files changed, 9 insertions(+), 57 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisConfig.java
index 7bdeab4..b660c83 100644
--- a/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisConfig.java
+++ b/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisConfig.java
@@ -1,87 +1,39 @@
package com.genersoft.iot.vmp.conf.redis;
-import com.alibaba.fastjson.parser.ParserConfig;
-import com.genersoft.iot.vmp.common.VideoManagerConstants;
-import com.genersoft.iot.vmp.service.impl.*;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cache.annotation.CachingConfigurerSupport;
+import com.alibaba.fastjson2.support.spring.data.redis.GenericFastJsonRedisSerializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.core.annotation.Order;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.data.redis.listener.PatternTopic;
-import org.springframework.data.redis.listener.RedisMessageListenerContainer;
-import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
-
-import com.genersoft.iot.vmp.utils.redis.FastJsonRedisSerializer;
/**
- * @description:Redis涓棿浠堕厤缃被锛屼娇鐢╯pring-data-redis闆嗘垚锛岃嚜鍔ㄤ粠application.yml涓姞杞絩edis閰嶇疆
- * @author: swwheihei
- * @date: 2019骞�5鏈�30鏃� 涓婂崍10:58:25
+ * Redis涓棿浠堕厤缃被锛屼娇鐢╯pring-data-redis闆嗘垚锛岃嚜鍔ㄤ粠application.yml涓姞杞絩edis閰嶇疆
+ * swwheihei
+ * 2019骞�5鏈�30鏃� 涓婂崍10:58:25
*
*/
@Configuration
-public class RedisConfig extends CachingConfigurerSupport {
+@Order(value=1)
+public class RedisConfig {
- @Autowired
- private RedisGpsMsgListener redisGPSMsgListener;
-
- @Autowired
- private RedisAlarmMsgListener redisAlarmMsgListener;
-
- @Autowired
- private RedisStreamMsgListener redisStreamMsgListener;
-
- @Autowired
- private RedisGbPlayMsgListener redisGbPlayMsgListener;
-
- @Autowired
- private RedisPushStreamStatusMsgListener redisPushStreamStatusMsgListener;
-
- @Autowired
- private RedisPushStreamListMsgListener redisPushStreamListMsgListener;
@Bean
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
// 浣跨敤fastJson搴忓垪鍖�
- FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer(Object.class);
+ GenericFastJsonRedisSerializer fastJsonRedisSerializer = new GenericFastJsonRedisSerializer();
// value鍊肩殑搴忓垪鍖栭噰鐢╢astJsonRedisSerializer
redisTemplate.setValueSerializer(fastJsonRedisSerializer);
redisTemplate.setHashValueSerializer(fastJsonRedisSerializer);
- // 鍏ㄥ眬寮�鍚疉utoType锛屼笉寤鸿浣跨敤
- ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
+
// key鐨勫簭鍒楀寲閲囩敤StringRedisSerializer
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
redisTemplate.setConnectionFactory(redisConnectionFactory);
return redisTemplate;
}
-
-
- /**
- * redis娑堟伅鐩戝惉鍣ㄥ鍣� 鍙互娣诲姞澶氫釜鐩戝惉涓嶅悓璇濋鐨剅edis鐩戝惉鍣紝鍙渶瑕佹妸娑堟伅鐩戝惉鍣ㄥ拰鐩稿簲鐨勬秷鎭闃呭鐞嗗櫒缁戝畾锛岃娑堟伅鐩戝惉鍣�
- * 閫氳繃鍙嶅皠鎶�鏈皟鐢ㄦ秷鎭闃呭鐞嗗櫒鐨勭浉鍏虫柟娉曡繘琛屼竴浜涗笟鍔″鐞�
- *
- * @param connectionFactory
- * @return
- */
- @Bean
- RedisMessageListenerContainer container(RedisConnectionFactory connectionFactory) {
-
- RedisMessageListenerContainer container = new RedisMessageListenerContainer();
- container.setConnectionFactory(connectionFactory);
- container.addMessageListener(redisGPSMsgListener, new PatternTopic(VideoManagerConstants.VM_MSG_GPS));
- container.addMessageListener(redisAlarmMsgListener, new PatternTopic(VideoManagerConstants.VM_MSG_SUBSCRIBE_ALARM_RECEIVE));
- container.addMessageListener(redisStreamMsgListener, new PatternTopic(VideoManagerConstants.WVP_MSG_STREAM_CHANGE_PREFIX + "PUSH"));
- container.addMessageListener(redisGbPlayMsgListener, new PatternTopic(RedisGbPlayMsgListener.WVP_PUSH_STREAM_KEY));
- container.addMessageListener(redisPushStreamStatusMsgListener, new PatternTopic(VideoManagerConstants.VM_MSG_PUSH_STREAM_STATUS_CHANGE));
- container.addMessageListener(redisPushStreamListMsgListener, new PatternTopic(VideoManagerConstants.VM_MSG_PUSH_STREAM_LIST_CHANGE));
- return container;
- }
-
}
--
Gitblit v1.8.0