You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/06/28 21:20:25 UTC

[GitHub] [rocketmq] wl1092212424 commented on issue #1272: example OpenMessaging MQClientException No name server address, please set it.

wl1092212424 commented on issue #1272:
URL: https://github.com/apache/rocketmq/issues/1272#issuecomment-1169254271

   The reason is this, look at the source code
   `PushConsumerImpl`类的 `if ("true".equalsIgnoreCase(System.getenv("OMS_RMQ_DIRECT_NAME_SRV")))`
   ```java
   public PushConsumerImpl(final KeyValue properties) {
     this.rocketmqPushConsumer = new DefaultMQPushConsumer();
     this.properties = properties;
     this.clientConfig = BeanUtils.populate(properties, ClientConfig.class);
     if ("true".equalsIgnoreCase(System.getenv("OMS_RMQ_DIRECT_NAME_SRV"))) {
       String accessPoints = clientConfig.getAccessPoints();
       if (accessPoints == null || accessPoints.isEmpty()) {
         throw new OMSRuntimeException("-1", "OMS AccessPoints is null or empty.");
       }
       this.rocketmqPushConsumer.setNamesrvAddr(accessPoints.replace(',', ';'));
     }
     String consumerGroup = clientConfig.getConsumerId();
     if (null == consumerGroup || consumerGroup.isEmpty()) {
       throw new OMSRuntimeException("-1", "Consumer Group is necessary for RocketMQ, please set it.");
     }
     this.rocketmqPushConsumer.setConsumerGroup(consumerGroup);
     this.rocketmqPushConsumer.setMaxReconsumeTimes(clientConfig.getRmqMaxRedeliveryTimes());
     this.rocketmqPushConsumer.setConsumeTimeout(clientConfig.getRmqMessageConsumeTimeout());
     this.rocketmqPushConsumer.setConsumeThreadMax(clientConfig.getRmqMaxConsumeThreadNums());
     this.rocketmqPushConsumer.setConsumeThreadMin(clientConfig.getRmqMinConsumeThreadNums());
     String consumerId = OMSUtil.buildInstanceName();
     this.rocketmqPushConsumer.setInstanceName(consumerId);
     properties.put(OMSBuiltinKeys.CONSUMER_ID, consumerId);
     this.rocketmqPushConsumer.setLanguage(LanguageCode.OMS);
     this.rocketmqPushConsumer.registerMessageListener(new MessageListenerImpl());
   }
   ```


-- 
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: dev-unsubscribe@rocketmq.apache.org

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