Skip to content

Commit 6124695

Browse files
author
shutian.lzh
committed
Use access point url as name server conditionally
1 parent d6807c8 commit 6124695

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

openmessaging/src/main/java/io/openmessaging/rocketmq/producer/AbstractOMSProducer.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,15 @@ abstract class AbstractOMSProducer implements ServiceLifecycle, MessageFactory {
5252
this.rocketmqProducer = new DefaultMQProducer();
5353
this.clientConfig = BeanUtils.populate(properties, ClientConfig.class);
5454

55-
String accessPoints = clientConfig.getAccessPoints();
56-
if (accessPoints == null || accessPoints.isEmpty()) {
57-
throw new OMSRuntimeException("-1", "OMS AccessPoints is null or empty.");
55+
if ("true".equalsIgnoreCase(System.getenv("OMS_RMQ_DIRECT_NAME_SRV"))) {
56+
String accessPoints = clientConfig.getAccessPoints();
57+
if (accessPoints == null || accessPoints.isEmpty()) {
58+
throw new OMSRuntimeException("-1", "OMS AccessPoints is null or empty.");
59+
}
60+
61+
this.rocketmqProducer.setNamesrvAddr(accessPoints.replace(',', ';'));
5862
}
59-
this.rocketmqProducer.setNamesrvAddr(accessPoints.replace(',', ';'));
63+
6064
this.rocketmqProducer.setProducerGroup(clientConfig.getRmqProducerGroup());
6165

6266
String producerId = buildInstanceName();

0 commit comments

Comments
 (0)