Commit 5077b6cc authored by Jean Detoeuf's avatar Jean Detoeuf Committed by Dave Syer

Added ActiveMqCredentials (optional)

Fixes gh-618
parent d119336f
......@@ -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;
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment