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
a4c5c6a5
Commit
a4c5c6a5
authored
Aug 31, 2020
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改MQ请求尸体,防止出错
parent
64d7633a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
46 deletions
+9
-46
YzgMqConsumer.java
.../src/main/java/com/yanzuoguang/mq/plan/YzgMqConsumer.java
+1
-1
MessageServiceImpl.java
...a/com/yanzuoguang/mq/service/impl/MessageServiceImpl.java
+8
-5
MessageVo.java
...til-mq/src/main/java/com/yanzuoguang/mq/vo/MessageVo.java
+0
-40
No files found.
yzg-util-mq/src/main/java/com/yanzuoguang/mq/plan/YzgMqConsumer.java
View file @
a4c5c6a5
...
...
@@ -84,7 +84,7 @@ public class YzgMqConsumer {
*/
public
String
sendDelay
(
String
json
,
long
dedTime
)
{
if
(
dedTime
>
0
)
{
return
mqService
.
message
(
new
MessageVo
(
YZG_MQ_SYSTEM_QUEUE_DELAY
,
YZG_MQ_SYSTEM_QUEUE_DELAY
,
json
,
dedTime
,
true
));
return
mqService
.
message
(
new
MessageVo
(
YZG_MQ_SYSTEM_QUEUE_DELAY
,
YZG_MQ_SYSTEM_QUEUE_DELAY
,
json
,
dedTime
));
}
else
{
return
mqService
.
message
(
new
MessageVo
(
YZG_MQ_SYSTEM_QUEUE
,
YZG_MQ_SYSTEM_QUEUE
,
json
));
}
...
...
yzg-util-mq/src/main/java/com/yanzuoguang/mq/service/impl/MessageServiceImpl.java
View file @
a4c5c6a5
...
...
@@ -69,7 +69,7 @@ public class MessageServiceImpl implements MessageService {
if
(!
StringHelper
.
isEmpty
(
req
.
getHandleTime
()))
{
long
dedTime
=
DateHelper
.
getDateTime
(
req
.
getHandleTime
()).
getTime
()
-
System
.
currentTimeMillis
();
req
.
setDedTime
(
dedTime
);
req
.
setDedTimeDefine
(
false
);
//
req.setDedTimeDefine(false);
// return messageDao.save(req);
}
return
sendContent
(
StringHelper
.
EMPTY
,
req
,
now
);
...
...
@@ -94,10 +94,13 @@ public class MessageServiceImpl implements MessageService {
* @return
*/
private
String
sendContent
(
String
messageId
,
MessageVo
req
,
boolean
now
)
{
if
(
req
.
getDedTime
()
>
0
&&
!
req
.
isDedTimeDefine
()
&&
!
now
)
{
// 延迟队列处理
req
.
setMessageId
(
messageId
);
return
yzgMqConsumer
.
sendDelay
(
req
);
if
(!
StringHelper
.
compare
(
req
.
getExchangeName
(),
YzgMqConsumer
.
YZG_MQ_SYSTEM_QUEUE_DELAY
)
&&
!
StringHelper
.
compare
(
req
.
getExchangeName
(),
YzgMqConsumer
.
YZG_MQ_SYSTEM_QUEUE
))
{
if
(
req
.
getDedTime
()
>
0
&&
!
now
)
{
// 延迟队列处理
req
.
setMessageId
(
messageId
);
return
yzgMqConsumer
.
sendDelay
(
req
);
}
}
messageId
=
StringHelper
.
getFirst
(
messageId
,
StringHelper
.
getId
(
"temp"
,
StringHelper
.
getNewID
()));
...
...
yzg-util-mq/src/main/java/com/yanzuoguang/mq/vo/MessageVo.java
View file @
a4c5c6a5
...
...
@@ -35,11 +35,6 @@ public class MessageVo extends BaseVo implements InitDao {
*/
private
String
message
;
/**
* 手动定义延迟队列
*/
private
boolean
dedTimeDefine
;
/**
* 延迟毫秒
*/
...
...
@@ -132,33 +127,6 @@ public class MessageVo extends BaseVo implements InitDao {
this
.
dedTime
=
dedTime
;
}
/**
* 构造函数
*
* @param exchangeNameRouteKey 交换器名称+路由键
* @param message 消息内容
* @param dedTime 过期时间
*/
public
MessageVo
(
String
exchangeNameRouteKey
,
String
message
,
long
dedTime
,
boolean
dedTimeDefine
)
{
this
(
exchangeNameRouteKey
,
exchangeNameRouteKey
,
message
,
dedTime
,
dedTimeDefine
);
}
/**
* 构造函数
*
* @param exchangeName 交换器名称
* @param routeKey 路由键
* @param message 消息内容
* @param dedTime 过期时间
*/
public
MessageVo
(
String
exchangeName
,
String
routeKey
,
String
message
,
long
dedTime
,
boolean
dedTimeDefine
)
{
this
.
exchangeName
=
exchangeName
;
this
.
routeKey
=
routeKey
;
this
.
message
=
message
;
this
.
dedTime
=
dedTime
;
this
.
dedTimeDefine
=
dedTimeDefine
;
}
/**
* 构造函数
*
...
...
@@ -214,14 +182,6 @@ public class MessageVo extends BaseVo implements InitDao {
this
.
dedTime
=
dedTime
;
}
public
boolean
isDedTimeDefine
()
{
return
dedTimeDefine
;
}
public
void
setDedTimeDefine
(
boolean
dedTimeDefine
)
{
this
.
dedTimeDefine
=
dedTimeDefine
;
}
public
int
getHandleCount
()
{
return
handleCount
;
}
...
...
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