From 3469271ec25c69e4528b085ba3be7d9d85ec519e Mon Sep 17 00:00:00 2001
From: 64850858 <648540858@qq.com>
Date: 星期一, 26 七月 2021 11:40:32 +0800
Subject: [PATCH] 优化集群方案, 每个zlm一套ssrc; 优化集群下的docker接入逻辑; 更正sql脚本; 支持重启不设置设备离线。重启SIP事务不丢失

---
 src/main/java/com/genersoft/iot/vmp/conf/RedisConfig.java |   37 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 36 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/conf/RedisConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/RedisConfig.java
index 0b3e23b..ee90788 100644
--- a/src/main/java/com/genersoft/iot/vmp/conf/RedisConfig.java
+++ b/src/main/java/com/genersoft/iot/vmp/conf/RedisConfig.java
@@ -1,5 +1,7 @@
 package com.genersoft.iot.vmp.conf;
 
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.cache.annotation.CachingConfigurerSupport;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -10,6 +12,8 @@
 
 import com.alibaba.fastjson.parser.ParserConfig;
 import com.genersoft.iot.vmp.utils.redis.FastJsonRedisSerializer;
+import redis.clients.jedis.JedisPool;
+import redis.clients.jedis.JedisPoolConfig;
 
 /**
  * @Description:Redis涓棿浠堕厤缃被锛屼娇鐢╯pring-data-redis闆嗘垚锛岃嚜鍔ㄤ粠application.yml涓姞杞絩edis閰嶇疆
@@ -19,6 +23,37 @@
  */
 @Configuration
 public class RedisConfig extends CachingConfigurerSupport {
+
+	@Value("${spring.redis.host}")
+	private String host;
+	@Value("${spring.redis.port}")
+	private int port;
+	@Value("${spring.redis.database}")
+	private int database;
+	@Value("${spring.redis.password}")
+	private String password;
+	@Value("${spring.redis.timeout}")
+	private int timeout;
+	@Value("${spring.redis.poolMaxTotal:1000}")
+	private int poolMaxTotal;
+	@Value("${spring.redis.poolMaxIdle:500}")
+	private int poolMaxIdle;
+	@Value("${spring.redis.poolMaxWait:5}")
+	private int poolMaxWait;
+
+	@Bean
+	public JedisPool jedisPool() {
+		if (StringUtils.isBlank(password)) {
+			password = null;
+		}
+		JedisPoolConfig poolConfig = new JedisPoolConfig();
+		poolConfig.setMaxIdle(poolMaxIdle);
+		poolConfig.setMaxTotal(poolMaxTotal);
+		// 绉掕浆姣
+		poolConfig.setMaxWaitMillis(poolMaxWait * 1000L);
+		JedisPool jp = new JedisPool(poolConfig, host, port, timeout * 1000, password, database);
+		return jp;
+	}
 
 	@Bean("redisTemplate")
 	public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
@@ -34,7 +69,7 @@
 		template.setHashKeySerializer(new StringRedisSerializer());
 		template.setConnectionFactory(redisConnectionFactory);
 		// 浣跨敤fastjson鏃堕渶璁剧疆姝ら」锛屽惁鍒欎細鎶ュ紓甯竛ot support type
-		ParserConfig.getGlobalInstance().setAutoTypeSupport(true); 
+		ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
 		return template;
 	}
 

--
Gitblit v1.8.0