1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
package com.yanzuoguang.mq.vo;
import com.yanzuoguang.dao.TableAnnotation;
import com.yanzuoguang.util.helper.CheckerHelper;
import com.yanzuoguang.util.helper.DateHelper;
import com.yanzuoguang.util.helper.StringHelper;
import com.yanzuoguang.util.vo.BaseVo;
import com.yanzuoguang.util.vo.InitDao;
/**
* 创建队列
*
* @author 颜佐光
*/
@TableAnnotation("Queue_Queue")
public class QueueVo extends BaseVo implements InitDao {
/**
* 队列编号
*/
private String queueId;
/**
* 队列名称
*/
private String queueName;
/**
* 交换器名称
*/
private String exchangeName;
/**
* 路由键
*/
private String routeKey;
/**
* 优先级队列
*/
private int priority;
/**
* 死信处理,在死信处理时,则死信交换器是有效的
*/
private long dedTime;
/**
* 死信处理交换器名称
*/
private String dedExchangeName;
/**
* 死信处理队列名称
*/
private String dedQueueName;
/**
* 死信处理路由键
*/
private String dedRouteKey;
/**
* 创建时间
*/
private String createDate;
/**
* 检测函数
*/
public void check() {
CheckerHelper check = CheckerHelper.newInstance()
.notBlankCheck("QueueName", this.getQueueName())
.notBlankCheck("ExchangeName", this.getExchangeName())
.notBlankCheck("RouteKey", this.getRouteKey())
.checkException(this);
if (this.getDedTime() > 0
|| !StringHelper.isEmpty(this.getDedQueueName())
|| !StringHelper.isEmpty(this.getDedExchangeName())
|| !StringHelper.isEmpty(this.getDedRouteKey())
) {
check.notBlankCheck("DelayQueueName", this.getDedQueueName())
.notBlankCheck("DelayExchangeName", this.getDedExchangeName())
.notBlankCheck("DelayRouteKey", this.getDedRouteKey())
.checkException(this);
}
}
/**
* 构造函数
*/
public QueueVo() {
}
/**
* 构造函数,用于创建延迟队列。</p>
* 会创建queueName、exchangeName并且通过routeKey绑定。
*
* @param queueName 队列名称
* @param exchangeName 交换器名称
* @param routeKey 路由键
*/
public QueueVo(String queueName, String exchangeName, String routeKey) {
this.queueName = queueName;
this.exchangeName = exchangeName;
this.routeKey = routeKey;
}
/**
* 构造函数,用于创建延迟队列。</p>
* 会创建queueName、exchangeName并且通过routeKey绑定。
*
* @param queueName 队列名称,交换器名称,路由键
*/
public QueueVo(String queueName) {
this.queueName = queueName;
this.exchangeName = queueName;
this.routeKey = queueName;
}
/**
* 构造函数,用于创建延迟队列。</p>
* 创建 queueName、exchangeName 并且通过 routeKey 绑定, 创建 dedQueueName、dedExchangeName 并且通过 dedRouteKey 绑定,
* 将 queueName 的死信队列设置为 dedExchangeName 和 dedRouteKey .
*
* @param queueName 队列名称
* @param exchangeName 交换器名称
* @param routeKey 路由键
* @param dedTime 死信时间
* @param dedExchangeName 死信交换器名称
* @param dedQueueName 死信交换队列名称
* @param dedRouteKey 死信路由键
*/
public QueueVo(String queueName, String exchangeName, String routeKey, long dedTime, String dedExchangeName, String dedQueueName, String dedRouteKey) {
this.queueName = queueName;
this.exchangeName = exchangeName;
this.routeKey = routeKey;
this.dedTime = dedTime;
this.dedExchangeName = dedExchangeName;
this.dedQueueName = dedQueueName;
this.dedRouteKey = dedRouteKey;
}
/**
* 构造函数,用于创建延迟队列。</p>
* 创建 queueName、exchangeName 并且通过 routeKey 绑定, 创建 dedQueueName、dedExchangeName 并且通过 dedRouteKey 绑定,
* 将 queueName 的死信队列设置为 dedExchangeName 和 dedRouteKey .
*
* @param queueName 队列名称,路由键,交换器名称
* @param dedTime 死信时间
* @param dedQueueName 死信交换器名称,死信交换队列名称,死信路由键
*/
public QueueVo(String queueName, long dedTime, String dedQueueName) {
this.queueName = queueName;
this.exchangeName = queueName;
this.routeKey = queueName;
this.dedTime = dedTime;
this.dedExchangeName = dedQueueName;
this.dedQueueName = dedQueueName;
this.dedRouteKey = dedQueueName;
}
public String getQueueId() {
return queueId;
}
public void setQueueId(String queueId) {
this.queueId = queueId;
}
public String getQueueName() {
return queueName;
}
public void setQueueName(String queueName) {
this.queueName = queueName;
}
public String getExchangeName() {
return exchangeName;
}
public void setExchangeName(String exchangeName) {
this.exchangeName = exchangeName;
}
public String getRouteKey() {
return routeKey;
}
public void setRouteKey(String routeKey) {
this.routeKey = routeKey;
}
public int getPriority() {
return priority;
}
public void setPriority(int priority) {
this.priority = priority;
}
public long getDedTime() {
return dedTime;
}
public void setDedTime(long dedTime) {
this.dedTime = dedTime;
}
public String getDedExchangeName() {
return dedExchangeName;
}
public void setDedExchangeName(String dedExchangeName) {
this.dedExchangeName = dedExchangeName;
}
public String getDedQueueName() {
return dedQueueName;
}
public void setDedQueueName(String dedQueueName) {
this.dedQueueName = dedQueueName;
}
public String getDedRouteKey() {
return dedRouteKey;
}
public void setDedRouteKey(String dedRouteKey) {
this.dedRouteKey = dedRouteKey;
}
public String getCreateDate() {
return createDate;
}
public void setCreateDate(String createDate) {
this.createDate = createDate;
}
@Override
public void init() {
this.dedExchangeName = StringHelper.getFirst(this.dedExchangeName, "");
this.dedQueueName = StringHelper.getFirst(this.dedQueueName, "");
this.dedRouteKey = StringHelper.getFirst(this.dedRouteKey, "");
this.createDate = StringHelper.getFirst(this.createDate, DateHelper.getNow());
}
}