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
aa14595e
Commit
aa14595e
authored
Dec 10, 2021
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
下载视频
parent
fbe4c9cc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
6 deletions
+28
-6
MessageSendService.java
...n/java/com/yanzuoguang/mq/service/MessageSendService.java
+12
-0
MessageSendServiceImpl.java
...m/yanzuoguang/mq/service/impl/MessageSendServiceImpl.java
+16
-6
No files found.
yzg-util-mq/src/main/java/com/yanzuoguang/mq/service/MessageSendService.java
View file @
aa14595e
...
@@ -77,4 +77,16 @@ public interface MessageSendService {
...
@@ -77,4 +77,16 @@ public interface MessageSendService {
*/
*/
@ApiOperation
(
value
=
"动态初始化消息队列处理"
)
@ApiOperation
(
value
=
"动态初始化消息队列处理"
)
SimpleMessageListenerContainer
init
(
String
queueName
,
int
concurrency
,
ChannelAwareMessageListener
messageListener
);
SimpleMessageListenerContainer
init
(
String
queueName
,
int
concurrency
,
ChannelAwareMessageListener
messageListener
);
/**
* 动态初始化消息队列处理
*
* @param queueName 队列名字
* @param concurrency 线程数量
* @param maxConcurrency 最大线程数量个
* @param messageListener 消息处理函数
* @return
*/
@ApiOperation
(
value
=
"动态初始化消息队列处理"
)
SimpleMessageListenerContainer
init
(
String
queueName
,
int
concurrency
,
int
maxConcurrency
,
ChannelAwareMessageListener
messageListener
);
}
}
yzg-util-mq/src/main/java/com/yanzuoguang/mq/service/impl/MessageSendServiceImpl.java
View file @
aa14595e
...
@@ -176,16 +176,26 @@ public class MessageSendServiceImpl implements MessageSendService {
...
@@ -176,16 +176,26 @@ public class MessageSendServiceImpl implements MessageSendService {
*/
*/
@Override
@Override
public
SimpleMessageListenerContainer
init
(
String
queueName
,
int
concurrency
,
ChannelAwareMessageListener
messageListener
)
{
public
SimpleMessageListenerContainer
init
(
String
queueName
,
int
concurrency
,
ChannelAwareMessageListener
messageListener
)
{
return
this
.
init
(
queueName
,
concurrency
,
concurrency
,
messageListener
);
}
/**
* 动态初始化消息队列处理
*
* @param queueName 队列名字
* @param concurrency 线程数量
* @param maxConcurrency 最大线程数量个
* @param messageListener 消息处理函数
* @return
*/
@Override
public
SimpleMessageListenerContainer
init
(
String
queueName
,
int
concurrency
,
int
maxConcurrency
,
ChannelAwareMessageListener
messageListener
)
{
SimpleMessageListenerContainer
container
=
new
SimpleMessageListenerContainer
();
SimpleMessageListenerContainer
container
=
new
SimpleMessageListenerContainer
();
container
.
setConnectionFactory
(
connectionFactory
);
container
.
setConnectionFactory
(
connectionFactory
);
container
.
setAcknowledgeMode
(
AcknowledgeMode
.
MANUAL
);
container
.
setAcknowledgeMode
(
AcknowledgeMode
.
MANUAL
);
container
.
setQueueNames
(
queueName
);
container
.
setQueueNames
(
queueName
);
if
(
concurrency
>
0
)
{
container
.
setConcurrentConsumers
(
StringHelper
.
getFirst
(
concurrency
,
this
.
mqConfig
.
getConcurrency
()));
container
.
setConcurrentConsumers
(
concurrency
);
container
.
setMaxConcurrentConsumers
(
StringHelper
.
getFirst
(
maxConcurrency
,
this
.
mqConfig
.
getMaxConcurrency
()));
}
else
{
container
.
setConcurrentConsumers
(
this
.
mqConfig
.
getConcurrency
());
}
container
.
setMaxConcurrentConsumers
(
this
.
mqConfig
.
getMaxConcurrency
());
container
.
setPrefetchCount
(
this
.
mqConfig
.
getPrefetch
());
container
.
setPrefetchCount
(
this
.
mqConfig
.
getPrefetch
());
container
.
setTxSize
(
this
.
mqConfig
.
getTxSize
());
container
.
setTxSize
(
this
.
mqConfig
.
getTxSize
());
container
.
setMessageListener
(
new
MessageListenerAdapter
(
messageListener
));
container
.
setMessageListener
(
new
MessageListenerAdapter
(
messageListener
));
...
...
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