记得上下班打卡 | git大法好,push需谨慎

Commit b9aa793d authored by 胡佳晨's avatar 胡佳晨

修改 redis队列消费指定 db

parent dff5eb31
...@@ -37,6 +37,8 @@ public abstract class AbstractRedisConfig { ...@@ -37,6 +37,8 @@ public abstract class AbstractRedisConfig {
public int totalDbs = 1; public int totalDbs = 1;
public int stringTemplateDb = 1;
public Map<Integer, RedisTemplate<String, Object>> redisTemplateMap = new HashMap<>(); public Map<Integer, RedisTemplate<String, Object>> redisTemplateMap = new HashMap<>();
private StringRedisTemplate stringRedisTemplate = new StringRedisTemplate(); private StringRedisTemplate stringRedisTemplate = new StringRedisTemplate();
...@@ -59,7 +61,7 @@ public abstract class AbstractRedisConfig { ...@@ -59,7 +61,7 @@ public abstract class AbstractRedisConfig {
return; return;
} }
defaultDb = this.getDbs().get(0); defaultDb = this.getDbs().get(0);
if(this.getDbs().size()==2&&this.getDbs().get(1)!=null){ if(this.getDbs().size()>=2&&this.getDbs().get(1)!=null){
totalDbs = this.getDbs().get(1); totalDbs = this.getDbs().get(1);
log.info("init totalDbs : {}",totalDbs); log.info("init totalDbs : {}",totalDbs);
for (int i = 0;i < totalDbs; i++) { for (int i = 0;i < totalDbs; i++) {
...@@ -75,6 +77,11 @@ public abstract class AbstractRedisConfig { ...@@ -75,6 +77,11 @@ public abstract class AbstractRedisConfig {
log.info("###### START 初始化 Redis-queue{} "+this.getClass().getSimpleName()+"连接池 START ######", this.getHost()); log.info("###### START 初始化 Redis-queue{} "+this.getClass().getSimpleName()+"连接池 START ######", this.getHost());
//初始化队列 //初始化队列
LettuceConnectionFactory factory = null; LettuceConnectionFactory factory = null;
if(this.getDbs().size()==3){
stringTemplateDb = this.getDbs().get(2);
}else{
stringTemplateDb = totalDbs-1;
}
if(totalDbs==1){ if(totalDbs==1){
log.info("###### 正在加载Redis-queue-db-" + defaultDb + " ######"); log.info("###### 正在加载Redis-queue-db-" + defaultDb + " ######");
factory = getDbFactory(defaultDb); factory = getDbFactory(defaultDb);
...@@ -156,7 +163,7 @@ public abstract class AbstractRedisConfig { ...@@ -156,7 +163,7 @@ public abstract class AbstractRedisConfig {
if(totalDbs==1){ if(totalDbs==1){
factory = getDbFactory(defaultDb); factory = getDbFactory(defaultDb);
}else{ }else{
factory = getDbFactory(totalDbs-1); factory = getDbFactory(stringTemplateDb);
} }
StringRedisTemplate stringRedisTemplate = new StringRedisTemplate(); StringRedisTemplate stringRedisTemplate = new StringRedisTemplate();
stringRedisTemplate.setConnectionFactory(factory); stringRedisTemplate.setConnectionFactory(factory);
......
...@@ -21,7 +21,7 @@ public class MQConst { ...@@ -21,7 +21,7 @@ public class MQConst {
private final String desc; private final String desc;
AdamQueue(String key, String group, String desc) { AdamQueue(String key, String group, String desc) {
this.key = "test:".concat(key); this.key = key;
this.group = group; this.group = group;
this.desc = desc; this.desc = desc;
} }
...@@ -62,7 +62,7 @@ public class MQConst { ...@@ -62,7 +62,7 @@ public class MQConst {
private final String desc; private final String desc;
KylinQueue(String key, String group, String desc) { KylinQueue(String key, String group, String desc) {
this.key = "test:".concat(key); this.key = key;
this.group = group; this.group = group;
this.desc = desc; this.desc = desc;
} }
...@@ -103,7 +103,7 @@ public class MQConst { ...@@ -103,7 +103,7 @@ public class MQConst {
private final String desc; private final String desc;
SweetQueue(String key, String group, String desc) { SweetQueue(String key, String group, String desc) {
this.key = "test:".concat(key); this.key = key;
this.group = group; this.group = group;
this.desc = desc; this.desc = desc;
} }
...@@ -133,7 +133,7 @@ public class MQConst { ...@@ -133,7 +133,7 @@ public class MQConst {
private final String desc; private final String desc;
CandyQueue(String key, String group, String desc) { CandyQueue(String key, String group, String desc) {
this.key = "test:".concat(key); this.key = key;
this.group = group; this.group = group;
this.desc = desc; this.desc = desc;
} }
...@@ -168,7 +168,7 @@ public class MQConst { ...@@ -168,7 +168,7 @@ public class MQConst {
private final String desc; private final String desc;
SlimeQueue(String key, String group, String desc) { SlimeQueue(String key, String group, String desc) {
this.key = "test:".concat(key); this.key = key;
this.group = group; this.group = group;
this.desc = desc; this.desc = desc;
} }
...@@ -198,7 +198,7 @@ public class MQConst { ...@@ -198,7 +198,7 @@ public class MQConst {
private final String desc; private final String desc;
StoneQueue(String key, String group, String desc) { StoneQueue(String key, String group, String desc) {
this.key = "test:".concat(key); this.key = key;
this.group = group; this.group = group;
this.desc = desc; this.desc = desc;
} }
...@@ -222,7 +222,7 @@ public class MQConst { ...@@ -222,7 +222,7 @@ public class MQConst {
private final String desc; private final String desc;
SmileQueue(String key, String group, String desc) { SmileQueue(String key, String group, String desc) {
this.key = "test:".concat(key); this.key = key;
this.group = group; this.group = group;
this.desc = desc; this.desc = desc;
} }
...@@ -247,7 +247,7 @@ public class MQConst { ...@@ -247,7 +247,7 @@ public class MQConst {
private final String desc; private final String desc;
ChimeQueue(String key, String group, String desc) { ChimeQueue(String key, String group, String desc) {
this.key = "test:".concat(key); this.key = key;
this.group = group; this.group = group;
this.desc = desc; this.desc = desc;
} }
...@@ -309,7 +309,7 @@ public class MQConst { ...@@ -309,7 +309,7 @@ public class MQConst {
private final String desc; private final String desc;
GoblinQueue(String key, String group, String desc) { GoblinQueue(String key, String group, String desc) {
this.key = "test:".concat(key); this.key = key;
this.group = group; this.group = group;
this.desc = desc; this.desc = desc;
} }
...@@ -340,7 +340,7 @@ public class MQConst { ...@@ -340,7 +340,7 @@ public class MQConst {
private final String desc; private final String desc;
GalaxyQueue(String key, String group, String desc) { GalaxyQueue(String key, String group, String desc) {
this.key = "test:".concat(key); this.key = key;
this.group = group; this.group = group;
this.desc = desc; this.desc = desc;
} }
......
...@@ -33,43 +33,43 @@ liquidnet: ...@@ -33,43 +33,43 @@ liquidnet:
redis: redis:
kylin: kylin:
database: 255 database: 255
dbs: 0,256 dbs: 0,256,251
host: r-2zeucai3yj2t0f4nmzpd.redis.rds.aliyuncs.com host: r-2zeucai3yj2t0f4nmzpd.redis.rds.aliyuncs.com
port: 6380 port: 6380
password: 7eoK2XehKqF1 password: 7eoK2XehKqF1
goblin: goblin:
database: 255 database: 255
dbs: 0,256 dbs: 0,256,251
host: r-2zeucai3yj2t0f4nmzpd.redis.rds.aliyuncs.com host: r-2zeucai3yj2t0f4nmzpd.redis.rds.aliyuncs.com
port: 6380 port: 6380
password: 7eoK2XehKqF1 password: 7eoK2XehKqF1
slime: slime:
database: 255 database: 255
dbs: 0,256 dbs: 0,256,251
host: r-2zeucai3yj2t0f4nmzpd.redis.rds.aliyuncs.com host: r-2zeucai3yj2t0f4nmzpd.redis.rds.aliyuncs.com
port: 6380 port: 6380
password: 7eoK2XehKqF1 password: 7eoK2XehKqF1
dragon: dragon:
database: 255 database: 255
dbs: 0,256 dbs: 0,256,251
host: r-2zeucai3yj2t0f4nmzpd.redis.rds.aliyuncs.com host: r-2zeucai3yj2t0f4nmzpd.redis.rds.aliyuncs.com
port: 6380 port: 6380
password: 7eoK2XehKqF1 password: 7eoK2XehKqF1
sweet: sweet:
database: 255 database: 255
dbs: 0,256 dbs: 0,256,251
host: r-2zeucai3yj2t0f4nmzpd.redis.rds.aliyuncs.com host: r-2zeucai3yj2t0f4nmzpd.redis.rds.aliyuncs.com
port: 6380 port: 6380
password: 7eoK2XehKqF1 password: 7eoK2XehKqF1
adam: adam:
database: 255 database: 255
dbs: 0,256 dbs: 0,256,251
host: r-2zeucai3yj2t0f4nmzpd.redis.rds.aliyuncs.com host: r-2zeucai3yj2t0f4nmzpd.redis.rds.aliyuncs.com
port: 6380 port: 6380
password: 7eoK2XehKqF1 password: 7eoK2XehKqF1
candy: candy:
database: 255 database: 255
dbs: 0,256 dbs: 0,256,251
host: r-2zeucai3yj2t0f4nmzpd.redis.rds.aliyuncs.com host: r-2zeucai3yj2t0f4nmzpd.redis.rds.aliyuncs.com
port: 6380 port: 6380
password: 7eoK2XehKqF1 password: 7eoK2XehKqF1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment