diff --git a/src/main/java/org/apache/rocketmq/dashboard/config/RMQConfigure.java b/src/main/java/org/apache/rocketmq/dashboard/config/RMQConfigure.java index 991a2d8e..0a431eca 100644 --- a/src/main/java/org/apache/rocketmq/dashboard/config/RMQConfigure.java +++ b/src/main/java/org/apache/rocketmq/dashboard/config/RMQConfigure.java @@ -38,6 +38,8 @@ @Configuration @ConfigurationProperties(prefix = "rocketmq.config") public class RMQConfigure { + private static final String ROCKET_MQ_AK_PROPERTY = "rocketmq.config.accessKey"; + private static final String ROCKET_MQ_SK_PROPERTY = "rocketmq.config.secretKey"; private Logger logger = LoggerFactory.getLogger(RMQConfigure.class); //use rocketmq.namesrv.addr first,if it is empty,than use system proerty or system env @@ -52,9 +54,9 @@ public class RMQConfigure { private boolean loginRequired = false; - private String accessKey; + private String accessKey = System.getProperty(ROCKET_MQ_AK_PROPERTY, System.getenv("ROCKET_MQ_AK")); - private String secretKey; + private String secretKey = System.getProperty(ROCKET_MQ_SK_PROPERTY, System.getenv("ROCKET_MQ_SK")); private boolean useTLS = false; @@ -67,7 +69,11 @@ public String getAccessKey() { } public void setAccessKey(String accessKey) { - this.accessKey = accessKey; + if (StringUtils.isNotBlank(accessKey)) { + this.accessKey = accessKey; + System.setProperty(ROCKET_MQ_AK_PROPERTY, accessKey); + logger.info("setAccessKey accessKey={}", accessKey); + } } public String getSecretKey() { @@ -75,7 +81,11 @@ public String getSecretKey() { } public void setSecretKey(String secretKey) { - this.secretKey = secretKey; + if (StringUtils.isNotBlank(secretKey)) { + this.secretKey = secretKey; + System.setProperty(ROCKET_MQ_SK_PROPERTY, secretKey); + logger.info("setAccessKey accessKey={}", secretKey); + } } public String getNamesrvAddr() {