Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support set accessKey,secretKey params from VMOptions or SystemEnv #188

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;

Expand All @@ -67,15 +69,23 @@ 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() {
return secretKey;
}

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() {
Expand Down