Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YZG
yzg-util
Commits
4a15f7ad
Commit
4a15f7ad
authored
May 20, 2020
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
设置打包时可以通过GIT查看源码
parent
8cfa8cd1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
17 deletions
+32
-17
MqServiceImpl.java
...n/java/com/yanzuoguang/mq/service/impl/MqServiceImpl.java
+32
-17
No files found.
yzg-util-mq/src/main/java/com/yanzuoguang/mq/service/impl/MqServiceImpl.java
View file @
4a15f7ad
...
...
@@ -182,11 +182,33 @@ public class MqServiceImpl implements MqService {
*/
@Override
public
String
createServerQueue
(
ServerQueueReqVo
req
)
{
// 删除历史队列
removeServerQueue
(
req
);
// 创建主队列
String
queueName
=
req
.
getQueueName
();
String
localQueueName
=
this
.
getLocalName
(
req
.
getQueueName
());
this
.
createQueue
(
new
QueueVo
(
queueName
,
queueName
,
queueName
));
// 返回当前队列的名称
return
localQueueName
;
}
/**
* 注册当前消费队列的回调
*
* @param req 请求数据
* @param listener 处理函数
* @return
*/
@Override
public
String
setServerQueueConsumer
(
ServerQueueReqVo
req
,
ChannelAwareMessageListener
listener
)
{
// 队列名称
String
queueName
=
req
.
getQueueName
();
String
localQueueName
=
this
.
getLocalName
(
req
.
getQueueName
());
String
serverId
=
StringHelper
.
getMD5Id
(
localQueueName
);
this
.
createQueue
(
new
QueueVo
(
localQueueName
,
localQueueName
,
localQueueName
,
req
.
getServerWaitTime
(),
queueName
,
queueName
,
queueName
));
// 创建延迟队列和主队列的关系
this
.
createQueue
(
new
QueueVo
(
localQueueName
,
localQueueName
,
localQueueName
,
req
.
getServerWaitTime
(),
queueName
,
queueName
,
queueName
));
this
.
mqConsumeDynamic
.
init
(
queueName
,
new
ChannelAwareMessageListener
()
{
@Override
public
void
onMessage
(
Message
message
,
Channel
channel
)
throws
Exception
{
...
...
@@ -204,6 +226,7 @@ public class MqServiceImpl implements MqService {
}
});
// 注册到队列服务器到数据库表
QueueServerVo
vo
=
new
QueueServerVo
();
vo
.
setServerId
(
serverId
);
vo
.
setQueueName
(
queueName
);
...
...
@@ -214,26 +237,15 @@ public class MqServiceImpl implements MqService {
queueServerDao
.
update
(
vo
);
}
RegisterServerTokenReqVo
to
=
JsonHelper
.
to
(
req
,
RegisterServerTokenReqVo
.
class
);
// 注册本服务器的唯一识别编码
RegisterServerTokenReqVo
to
=
JsonHelper
.
to
(
req
,
RegisterServerTokenReqVo
.
class
);
to
.
setToken
(
localQueueName
);
this
.
registerServerToken
(
to
);
return
localQueueName
;
}
/**
* 注册当前消费队列的回调
*
* @param req 请求数据
* @param listener 处理函数
* @return
*/
@Override
public
String
setServerQueueConsumer
(
ServerQueueReqVo
req
,
ChannelAwareMessageListener
listener
)
{
String
localQueueName
=
this
.
getLocalName
(
req
.
getQueueName
());
// 设置延迟队列的回调函数
this
.
mqConsumeDynamic
.
init
(
localQueueName
,
listener
);
return
"注册成功"
;
return
localQueueName
;
}
/**
...
...
@@ -323,6 +335,9 @@ public class MqServiceImpl implements MqService {
// 发送消息,等待下次重新发送
req
.
addPos
();
if
(!
req
.
isNext
())
{
throw
new
CodeException
(
"达到最大次数,不会继续发送"
);
}
if
(
sendQueueName
.
isEmpty
())
{
String
json
=
JsonHelper
.
serialize
(
req
);
return
this
.
message
(
new
MessageVo
(
req
.
getQueueName
(),
req
.
getQueueName
(),
json
,
req
.
getNextDelayTime
()));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment