You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "miles-ton (via GitHub)" <gi...@apache.org> on 2023/03/25 11:14:21 UTC

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

miles-ton commented on code in PR #6463:
URL: https://github.com/apache/rocketmq/pull/6463#discussion_r1148352932


##########
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:
   yes, i think explicitly define NamesrvAddr will help new users to avoid unexpected null errors



-- 
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