Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
R
rocketmq
Project
Project
Details
Activity
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xrp
rocketmq
Commits
3288397b
Commit
3288397b
authored
Apr 20, 2021
by
mm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
demo
parent
a5d0a2f0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
ConsumerConfiguration.java
src/main/java/com/example/demo/mq/ConsumerConfiguration.java
+25
-0
No files found.
src/main/java/com/example/demo/mq/ConsumerConfiguration.java
View file @
3288397b
...
@@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.rocketmq.client.consumer.DefaultMQPushConsumer
;
import
org.apache.rocketmq.client.consumer.DefaultMQPushConsumer
;
import
org.apache.rocketmq.client.exception.MQClientException
;
import
org.apache.rocketmq.client.exception.MQClientException
;
import
org.apache.rocketmq.common.consumer.ConsumeFromWhere
;
import
org.apache.rocketmq.common.consumer.ConsumeFromWhere
;
import
org.apache.rocketmq.common.protocol.heartbeat.MessageModel
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -33,6 +34,30 @@ public class ConsumerConfiguration {
...
@@ -33,6 +34,30 @@ public class ConsumerConfiguration {
consumer
.
setConsumeFromWhere
(
ConsumeFromWhere
.
CONSUME_FROM_LAST_OFFSET
);
consumer
.
setConsumeFromWhere
(
ConsumeFromWhere
.
CONSUME_FROM_LAST_OFFSET
);
//订阅主题和 标签( * 代表所有标签)下信息
//订阅主题和 标签( * 代表所有标签)下信息
consumer
.
subscribe
(
"miyapaytest"
,
"*"
);
consumer
.
subscribe
(
"miyapaytest"
,
"*"
);
//设置多线程消费
/**
* 1.rocketMQ用的是ThreadPoolExecutor
*
* 2.ThreadPoolExecutor只有当任务队列满了才会启动大于核心线程数的新线程
*
* 3.rocketMQ传给ThreadPoolExecutor的队列是没设置容量的无界队列
*
* 4.所以任务队列基本不会满
*
* 5.所以ThreadPoolExecutor基本不会新建大于核心线程数的线程
*
* 6.所以rocketMQ设置的ConsumeThreadMax是无效的
*/
consumer
.
setConsumeThreadMax
(
50
);
consumer
.
setConsumeThreadMin
(
50
);
/**
* 设置广播模式加上这行代码
*/
// consumer.setMessageModel(MessageModel.BROADCASTING);
consumer
.
registerMessageListener
(
ledgerConsumerListener
);
consumer
.
registerMessageListener
(
ledgerConsumerListener
);
log
.
info
(
"消费者启动成功"
);
log
.
info
(
"消费者启动成功"
);
return
consumer
;
return
consumer
;
...
...
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