From 173f77d2c32019c8f5884a3adeb78d6f83aaa55c Mon Sep 17 00:00:00 2001 From: Zhanhui Li Date: Sat, 28 Apr 2018 05:01:29 +0800 Subject: [PATCH] BugFix: access point parsed as name server address when enabled for push / pull consumers --- .../rocketmq/consumer/PullConsumerImpl.java | 10 ++++++---- .../rocketmq/consumer/PushConsumerImpl.java | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/openmessaging/src/main/java/io/openmessaging/rocketmq/consumer/PullConsumerImpl.java b/openmessaging/src/main/java/io/openmessaging/rocketmq/consumer/PullConsumerImpl.java index 2e22509a..c11da585 100644 --- a/openmessaging/src/main/java/io/openmessaging/rocketmq/consumer/PullConsumerImpl.java +++ b/openmessaging/src/main/java/io/openmessaging/rocketmq/consumer/PullConsumerImpl.java @@ -60,11 +60,13 @@ public class PullConsumerImpl implements PullConsumer { this.rocketmqPullConsumer = pullConsumerScheduleService.getDefaultMQPullConsumer(); - String accessPoints = clientConfig.getAccessPoints(); - if (accessPoints == null || accessPoints.isEmpty()) { - throw new OMSRuntimeException("-1", "OMS AccessPoints is null or empty."); + 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.rocketmqPullConsumer.setNamesrvAddr(accessPoints.replace(',', ';')); } - this.rocketmqPullConsumer.setNamesrvAddr(accessPoints.replace(',', ';')); this.rocketmqPullConsumer.setConsumerGroup(consumerGroup); diff --git a/openmessaging/src/main/java/io/openmessaging/rocketmq/consumer/PushConsumerImpl.java b/openmessaging/src/main/java/io/openmessaging/rocketmq/consumer/PushConsumerImpl.java index 9bfd7c8b..46f6775e 100644 --- a/openmessaging/src/main/java/io/openmessaging/rocketmq/consumer/PushConsumerImpl.java +++ b/openmessaging/src/main/java/io/openmessaging/rocketmq/consumer/PushConsumerImpl.java @@ -52,11 +52,13 @@ public class PushConsumerImpl implements PushConsumer { this.properties = properties; this.clientConfig = BeanUtils.populate(properties, ClientConfig.class); - String accessPoints = clientConfig.getAccessPoints(); - if (accessPoints == null || accessPoints.isEmpty()) { - throw new OMSRuntimeException("-1", "OMS AccessPoints is null or empty."); + 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(',', ';')); } - this.rocketmqPushConsumer.setNamesrvAddr(accessPoints.replace(',', ';')); String consumerGroup = clientConfig.getConsumerId(); if (null == consumerGroup || consumerGroup.isEmpty()) { -- GitLab