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

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

修改 redis队列消费指定 db

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