You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by ji...@apache.org on 2023/03/27 05:42:36 UTC

[rocketmq] branch develop updated: [ISSUE #6462] Optimize PushConsumer code and logic (#6463)

This is an automated email from the ASF dual-hosted git repository.

jinrongtong pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git


The following commit(s) were added to refs/heads/develop by this push:
     new cc9321db4 [ISSUE #6462] Optimize PushConsumer code and logic (#6463)
cc9321db4 is described below

commit cc9321db49f784e68f4fbf1c3eeb138eb8a74165
Author: YonminMa <20...@qq.com>
AuthorDate: Mon Mar 27 13:42:29 2023 +0800

    [ISSUE #6462] Optimize PushConsumer code and logic (#6463)
    
    * [ISSUE #6462] Optimize PushConsumer code and logic
    
    * [ISSUE #6462] Optimize PushConsumer code and logic
---
 .../org/apache/rocketmq/example/simple/PushConsumer.java    | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/example/src/main/java/org/apache/rocketmq/example/simple/PushConsumer.java b/example/src/main/java/org/apache/rocketmq/example/simple/PushConsumer.java
index abbfbdffc..9de2b01d4 100644
--- a/example/src/main/java/org/apache/rocketmq/example/simple/PushConsumer.java
+++ b/example/src/main/java/org/apache/rocketmq/example/simple/PushConsumer.java
@@ -26,10 +26,17 @@ import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
 import org.apache.rocketmq.common.message.MessageExt;
 
 public class PushConsumer {
-
+    public static final String TOPIC = "TopicTest";
+    public static final String CONSUMER_GROUP = "CID_JODIE_1";
+    public static final String NAMESRV_ADDR = "127.0.0.1:9876";
     public static void main(String[] args) throws InterruptedException, MQClientException {
-        DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("CID_JODIE_1");
-        consumer.subscribe("TopicTest", "*");
+
+        DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(CONSUMER_GROUP);
+
+        // Uncomment the following line while debugging, namesrvAddr should be set to your local address
+//        consumer.setNamesrvAddr(NAMESRV_ADDR);
+
+        consumer.subscribe(TOPIC, "*");
         consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
         //wrong time format 2017_0422_221800
         consumer.setConsumeTimestamp("20181109221800");