Added ActiveMqCredentials (optional)
Fixes gh-618
This commit is contained in:
@@ -32,6 +32,10 @@ public class ActiveMQProperties {
|
||||
|
||||
private boolean pooled = false;
|
||||
|
||||
private String user;
|
||||
|
||||
private String password;
|
||||
|
||||
// Will override brokerURL if inMemory is set to true
|
||||
public String getBrokerUrl() {
|
||||
if (this.inMemory) {
|
||||
@@ -60,4 +64,20 @@ public class ActiveMQProperties {
|
||||
this.pooled = pooled;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return this.user;
|
||||
}
|
||||
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return this.password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -64,15 +64,26 @@ public class JmsTemplateAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
public ConnectionFactory jmsConnectionFactory() {
|
||||
ConnectionFactory connectionFactory;
|
||||
if (this.config.getUser() != null && !"".equals(this.config.getUser())
|
||||
&& this.config.getPassword() != null
|
||||
&& !"".equals(this.config.getPassword())) {
|
||||
connectionFactory = new ActiveMQConnectionFactory(this.config.getUser(),
|
||||
this.config.getPassword(), this.config.getBrokerUrl());
|
||||
}
|
||||
else {
|
||||
connectionFactory = new ActiveMQConnectionFactory(
|
||||
this.config.getBrokerUrl());
|
||||
}
|
||||
if (this.config.isPooled()) {
|
||||
PooledConnectionFactory pool = new PooledConnectionFactory();
|
||||
pool.setConnectionFactory(new ActiveMQConnectionFactory(this.config
|
||||
.getBrokerUrl()));
|
||||
pool.setConnectionFactory(connectionFactory);
|
||||
return pool;
|
||||
}
|
||||
return new ActiveMQConnectionFactory(this.config.getBrokerUrl());
|
||||
else {
|
||||
return connectionFactory;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user