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
e3f38cad
Commit
e3f38cad
authored
Aug 10, 2021
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改实例化关系
parent
b04da154
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
4 deletions
+22
-4
StringHelper.java
...c/main/java/com/yanzuoguang/util/helper/StringHelper.java
+12
-0
MessageSendServiceImpl.java
...m/yanzuoguang/mq/service/impl/MessageSendServiceImpl.java
+2
-4
MqServiceImpl.java
...n/java/com/yanzuoguang/mq/service/impl/MqServiceImpl.java
+8
-0
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/StringHelper.java
View file @
e3f38cad
...
@@ -1007,6 +1007,18 @@ public class StringHelper {
...
@@ -1007,6 +1007,18 @@ public class StringHelper {
return
getMD5Id
(
froms
);
return
getMD5Id
(
froms
);
}
}
/**
* 获取组合编号
*
* @param args 需要组合的编号
* @return 将ID列表进行组合生成ID
*/
public
static
String
getIdShort
(
String
from
,
Object
...
args
)
{
String
id
=
getId
(
args
);
return
from
.
replaceFirst
(
id
,
""
);
}
/**
/**
* 获取组合编号
* 获取组合编号
*
*
...
...
yzg-util-mq/src/main/java/com/yanzuoguang/mq/service/impl/MessageSendServiceImpl.java
View file @
e3f38cad
...
@@ -77,12 +77,11 @@ public class MessageSendServiceImpl implements MessageSendService {
...
@@ -77,12 +77,11 @@ public class MessageSendServiceImpl implements MessageSendService {
@Override
@Override
public
String
send
(
MessageVo
req
)
{
public
String
send
(
MessageVo
req
)
{
req
.
check
();
req
.
check
();
// 获取消息临时Id
// 获取消息临时Id
,消息Id为空时标识为第一次发送,并设置默认消息Id
String
finalMessageId
=
StringHelper
.
getFirst
(
req
.
getMessageId
(),
StringHelper
.
getId
(
"temp"
,
StringHelper
.
getNewID
()));
String
finalMessageId
=
StringHelper
.
getFirst
(
req
.
getMessageId
(),
StringHelper
.
getId
(
"temp"
,
StringHelper
.
getNewID
()));
// 设置编号
// 设置编号
CorrelationData
correlationData
=
new
CorrelationData
();
CorrelationData
correlationData
=
new
CorrelationData
();
correlationData
.
setId
(
finalMessageId
);
correlationData
.
setId
(
finalMessageId
);
rabbitTemplate
.
getRabbitTemplate
().
convertAndSend
(
req
.
getExchangeName
(),
req
.
getRouteKey
(),
req
.
getMessage
(),
new
MessagePostProcessor
()
{
rabbitTemplate
.
getRabbitTemplate
().
convertAndSend
(
req
.
getExchangeName
(),
req
.
getRouteKey
(),
req
.
getMessage
(),
new
MessagePostProcessor
()
{
@Override
@Override
public
Message
postProcessMessage
(
Message
message
)
throws
AmqpException
{
public
Message
postProcessMessage
(
Message
message
)
throws
AmqpException
{
...
@@ -91,8 +90,7 @@ public class MessageSendServiceImpl implements MessageSendService {
...
@@ -91,8 +90,7 @@ public class MessageSendServiceImpl implements MessageSendService {
// 设置持久化
// 设置持久化
properties
.
setDeliveryMode
(
MessageDeliveryMode
.
PERSISTENT
);
properties
.
setDeliveryMode
(
MessageDeliveryMode
.
PERSISTENT
);
// 设置消息编号
// 设置消息编号
properties
.
setMessageId
(
finalMessageId
);
properties
.
setMessageId
(
StringHelper
.
getIdShort
(
finalMessageId
,
"temp"
));
if
(
req
.
getDedTime
()
>
0
)
{
if
(
req
.
getDedTime
()
>
0
)
{
properties
.
setExpiration
(
req
.
getDedTime
()
+
""
);
properties
.
setExpiration
(
req
.
getDedTime
()
+
""
);
}
}
...
...
yzg-util-mq/src/main/java/com/yanzuoguang/mq/service/impl/MqServiceImpl.java
View file @
e3f38cad
...
@@ -6,6 +6,7 @@ import com.yanzuoguang.mq.service.*;
...
@@ -6,6 +6,7 @@ import com.yanzuoguang.mq.service.*;
import
com.yanzuoguang.mq.vo.MessageVo
;
import
com.yanzuoguang.mq.vo.MessageVo
;
import
com.yanzuoguang.mq.vo.QueueVo
;
import
com.yanzuoguang.mq.vo.QueueVo
;
import
com.yanzuoguang.mq.vo.req.*
;
import
com.yanzuoguang.mq.vo.req.*
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
org.springframework.amqp.core.Message
;
import
org.springframework.amqp.core.Message
;
import
org.springframework.amqp.rabbit.core.ChannelAwareMessageListener
;
import
org.springframework.amqp.rabbit.core.ChannelAwareMessageListener
;
import
org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer
;
import
org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer
;
...
@@ -67,6 +68,13 @@ public class MqServiceImpl implements MqService {
...
@@ -67,6 +68,13 @@ public class MqServiceImpl implements MqService {
@Override
@Override
public
String
message
(
MessageVo
req
,
boolean
now
)
{
public
String
message
(
MessageVo
req
,
boolean
now
)
{
req
.
check
();
req
.
check
();
// 设置默认消息Id
String
defaultId
=
StringHelper
.
getFirst
(
req
.
getMessageId
(),
StringHelper
.
getNewID
());
// 将Id去掉temp:
String
simpleId
=
StringHelper
.
getIdShort
(
defaultId
,
"temp"
);
// 增加temp标识第一次发送
req
.
setMessageId
(
StringHelper
.
getId
(
"temp"
,
simpleId
));
return
yzgMqProcedure
.
send
(
req
,
now
);
return
yzgMqProcedure
.
send
(
req
,
now
);
}
}
...
...
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