You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "YonminMa (via GitHub)" <gi...@apache.org> on 2023/03/24 07:10:54 UTC

[GitHub] [rocketmq] YonminMa commented on a diff in pull request #6463: [ISSUE #6462] Optimize PushConsumer code and logic

YonminMa commented on code in PR #6463:
URL: https://github.com/apache/rocketmq/pull/6463#discussion_r1147194001


##########
example/src/main/java/org/apache/rocketmq/example/simple/PushConsumer.java:
##########
@@ -26,10 +26,14 @@
 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);
+        consumer.setNamesrvAddr(NAMESRV_ADDR);

Review Comment:
   For most people who have just used RocketMQ, they just want to successfully run the PushConsumer, but they will get a "connect to null failed" message. In addition, namesrvAddr is also hard coded in PullConsumer, so I think hard coding namesrvAddr is helpful for novices who have just learned RocketMQ.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org