Skip to content

Commit 153f4dc

Browse files
committed
支持Topic管理能力
1 parent 0f085e4 commit 153f4dc

File tree

16 files changed

+1870
-17
lines changed

16 files changed

+1870
-17
lines changed

doc/db/tables_xxl_mq.sql

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,23 @@ SET NAMES utf8mb4;
1111
## —————————————————————— topic and message ——————————————————
1212

1313
CREATE TABLE `xxl_mq_topic`(
14-
`id` bigint(20) NOT NULL AUTO_INCREMENT,
15-
`topic` varchar(255) NOT NULL COMMENT '消息主题Topic',
16-
`name` varchar(100) NOT NULL COMMENT '消息主题名称',
17-
`owner` varchar(50) NOT NULL COMMENT '负责人',
18-
`alarm_email` varchar(255) DEFAULT NULL COMMENT '告警配置(邮箱)',
19-
`status` tinyint(4) NOT NULL COMMENT '状态:0-正常、1-禁用',
20-
`store_strategy` tinyint(4) NOT NULL COMMENT '存储策略:0-统一存储,2-隔离存储',
21-
`partition_strategy` tinyint(4) NOT NULL COMMENT '分区策略:0-Hash分区,1-随机分区,2-轮询分区',
22-
`level` int(11) NOT NULL COMMENT '优先级',
23-
`retry_type` varchar(100) NOT NULL COMMENT '重试策略(固定;增长;指数;不重试;)',
24-
`retry_count` int(11) NOT NULL COMMENT '重试次数',
25-
`retry_interval` int(11) NOT NULL COMMENT '重试间隔,单位秒(3s;3/6/9;3/9/27)',
26-
`execution_timeout` int(11) NOT NULL COMMENT '执行超时时间',
27-
`add_time` datetime NOT NULL COMMENT '新增时间',
28-
`update_time` datetime NOT NULL COMMENT '更新时间',
14+
`id` bigint(20) NOT NULL AUTO_INCREMENT,
15+
`appname` varchar(50) NOT NULL COMMENT 'AppName(服务唯一标识)',
16+
`topic` varchar(100) NOT NULL COMMENT '消息主题Topic',
17+
`desc` varchar(50) NOT NULL COMMENT '消息主题描述',
18+
`owner` varchar(50) NOT NULL COMMENT '负责人',
19+
`alarm_email` varchar(200) DEFAULT NULL COMMENT '告警配置(邮箱)',
20+
`status` tinyint(4) NOT NULL COMMENT '状态(正常;禁用)',
21+
`store_strategy` varchar(20) NOT NULL COMMENT '存储策略(统一存储;隔离存储)',
22+
`archive_strategy` varchar(20) NOT NULL COMMENT '归档策略(归档保留7天;归档保留30天;归档保留90天;归档永久保留;不归档直接清理;)',
23+
`partition_strategy` varchar(20) NOT NULL COMMENT '分区策略(Hash分区路由;随机分区路由;轮询分区路由)',
24+
`retry_strategy` varchar(20) NOT NULL COMMENT '重试策略(固定间隔重试;线性退避重试;指数退避重试;)',
25+
`retry_count` int(11) NOT NULL COMMENT '重试次数',
26+
`retry_interval` int(11) NOT NULL COMMENT '重试间隔,单位秒(3s;3/6/9;3/9/27;)',
27+
`level` tinyint(4) NOT NULL COMMENT '优先级,默认5级',
28+
`execution_timeout` int(11) NOT NULL COMMENT '执行超时时间',
29+
`add_time` datetime NOT NULL COMMENT '新增时间',
30+
`update_time` datetime NOT NULL COMMENT '更新时间',
2931
PRIMARY KEY (`id`),
3032
UNIQUE KEY `uni_topic` (`topic`) USING BTREE
3133
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT ='消息主题';
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.xxl.mq.admin.constant.enums;
2+
3+
/**
4+
* Archive Strategy
5+
* @author xuxueli
6+
*/
7+
public enum ArchiveStrategyEnum {
8+
9+
RESERVE_7_DAY(1, "归档保留7天"),
10+
RESERVE_30_DAY(2, "归档保留30天"),
11+
RESERVE_90_DAY(3, "归档保留90天"),
12+
RESERVE_FOREVER(9, "归档永久保留"),
13+
NONE(10, "不归档直接清理");
14+
15+
private int value;
16+
private String desc;
17+
18+
ArchiveStrategyEnum(int value, String desc) {
19+
this.value = value;
20+
this.desc = desc;
21+
}
22+
23+
public int getValue() {
24+
return value;
25+
}
26+
27+
public void setValue(int value) {
28+
this.value = value;
29+
}
30+
31+
public String getDesc() {
32+
return desc;
33+
}
34+
35+
public void setDesc(String desc) {
36+
this.desc = desc;
37+
}
38+
39+
public static ArchiveStrategyEnum match(int value, ArchiveStrategyEnum defaultItem){
40+
for (ArchiveStrategyEnum item: ArchiveStrategyEnum.values()) {
41+
if (item.value == value) {
42+
return item;
43+
}
44+
}
45+
return defaultItem;
46+
}
47+
48+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.xxl.mq.admin.constant.enums;
2+
3+
/**
4+
* Partition Route Strategy
5+
*
6+
* @author xuxueli
7+
*/
8+
public enum PartitionRouteStrategyEnum {
9+
10+
HASH(1, "Hash分区路由"),
11+
RANDOM(2, "随机分区路由"),
12+
CYCLE(3, "轮询分区路由");
13+
14+
private int value;
15+
private String desc;
16+
17+
PartitionRouteStrategyEnum(int value, String desc) {
18+
this.value = value;
19+
this.desc = desc;
20+
}
21+
22+
public int getValue() {
23+
return value;
24+
}
25+
26+
public void setValue(int value) {
27+
this.value = value;
28+
}
29+
30+
public String getDesc() {
31+
return desc;
32+
}
33+
34+
public void setDesc(String desc) {
35+
this.desc = desc;
36+
}
37+
38+
public static PartitionRouteStrategyEnum match(int value, PartitionRouteStrategyEnum defaultItem){
39+
for (PartitionRouteStrategyEnum item: PartitionRouteStrategyEnum.values()) {
40+
if (item.value == value) {
41+
return item;
42+
}
43+
}
44+
return defaultItem;
45+
}
46+
47+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.xxl.mq.admin.constant.enums;
2+
3+
/**
4+
* Retry Strategy
5+
* @author xuxueli
6+
*/
7+
public enum RetryStrategyEnum {
8+
9+
FIXED_RETREAT(1, "固定间隔重试"),
10+
LINEAR_RETREAT(2, "线性退避重试"),
11+
EXPONENTIAL_RETREAT(3, "指数退避重试");
12+
13+
private int value;
14+
private String desc;
15+
16+
RetryStrategyEnum(int value, String desc) {
17+
this.value = value;
18+
this.desc = desc;
19+
}
20+
21+
public int getValue() {
22+
return value;
23+
}
24+
25+
public void setValue(int value) {
26+
this.value = value;
27+
}
28+
29+
public String getDesc() {
30+
return desc;
31+
}
32+
33+
public void setDesc(String desc) {
34+
this.desc = desc;
35+
}
36+
37+
public static RetryStrategyEnum match(int value, RetryStrategyEnum defaultItem){
38+
for (RetryStrategyEnum item: RetryStrategyEnum.values()) {
39+
if (item.value == value) {
40+
return item;
41+
}
42+
}
43+
return defaultItem;
44+
}
45+
46+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.xxl.mq.admin.constant.enums;
2+
3+
/**
4+
* Store Strategy
5+
* @author xuxueli
6+
*/
7+
public enum StoreStrategyEnum {
8+
9+
UNITY_STORE(0, "统一存储")/*,
10+
SEPARATE_STORE(1, "隔离存储")*/;
11+
12+
private int value;
13+
private String desc;
14+
15+
StoreStrategyEnum(int value, String desc) {
16+
this.value = value;
17+
this.desc = desc;
18+
}
19+
20+
public int getValue() {
21+
return value;
22+
}
23+
24+
public void setValue(int value) {
25+
this.value = value;
26+
}
27+
28+
public String getDesc() {
29+
return desc;
30+
}
31+
32+
public void setDesc(String desc) {
33+
this.desc = desc;
34+
}
35+
36+
public static StoreStrategyEnum match(int value, StoreStrategyEnum defaultItem){
37+
for (StoreStrategyEnum item: StoreStrategyEnum.values()) {
38+
if (item.value == value) {
39+
return item;
40+
}
41+
}
42+
return defaultItem;
43+
}
44+
45+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.xxl.mq.admin.constant.enums;
2+
3+
/**
4+
* Topic Level Strategy
5+
*
6+
* @author xuxueli
7+
*/
8+
public enum TopicLevelStrategyEnum {
9+
10+
LEVEL_1(1, "1级"),
11+
LEVEL_2(2, "2级"),
12+
LEVEL_3(3, "3级"),
13+
LEVEL_4(4, "4级"),
14+
LEVEL_5(5, "5级");
15+
16+
private int value;
17+
private String desc;
18+
19+
TopicLevelStrategyEnum(int value, String desc) {
20+
this.value = value;
21+
this.desc = desc;
22+
}
23+
24+
public int getValue() {
25+
return value;
26+
}
27+
28+
public void setValue(int value) {
29+
this.value = value;
30+
}
31+
32+
public String getDesc() {
33+
return desc;
34+
}
35+
36+
public void setDesc(String desc) {
37+
this.desc = desc;
38+
}
39+
40+
public static TopicLevelStrategyEnum match(int value, TopicLevelStrategyEnum defaultItem){
41+
for (TopicLevelStrategyEnum item: TopicLevelStrategyEnum.values()) {
42+
if (item.value == value) {
43+
return item;
44+
}
45+
}
46+
return defaultItem;
47+
}
48+
49+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.xxl.mq.admin.constant.enums;
2+
3+
/**
4+
* Topic Status
5+
*
6+
* @author xuxueli
7+
*/
8+
public enum TopicStatusEnum {
9+
10+
NORMAL(0, "正常"),
11+
INACTIVE(1, "禁用");
12+
13+
private int value;
14+
private String desc;
15+
16+
TopicStatusEnum(int value, String desc) {
17+
this.value = value;
18+
this.desc = desc;
19+
}
20+
21+
public int getValue() {
22+
return value;
23+
}
24+
25+
public void setValue(int value) {
26+
this.value = value;
27+
}
28+
29+
public String getDesc() {
30+
return desc;
31+
}
32+
33+
public void setDesc(String desc) {
34+
this.desc = desc;
35+
}
36+
37+
public static TopicStatusEnum match(int value, TopicStatusEnum defaultItem){
38+
for (TopicStatusEnum item: TopicStatusEnum.values()) {
39+
if (item.value == value) {
40+
return item;
41+
}
42+
}
43+
return defaultItem;
44+
}
45+
46+
}

0 commit comments

Comments
 (0)