Skip to content

Commit

Permalink
Merge pull request #16 from openMF/feature/15-Add-username-password-h…
Browse files Browse the repository at this point in the history
…andling-for-the-message-broker-factory

Add username/password handling for the message broker factory
  • Loading branch information
adamsaghy authored Nov 7, 2023
2 parents a86ede7 + 6b379e6 commit 2278ede
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
package org.test.consumer.config;


import org.apache.activemq.ActiveMQConnectionFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;

@Configuration
public class MessageConsumerJMSBrokerConfiguration {

@Value("${brokerurl}")
private String brokerUrl;

@Value("${brokerusername")
private String brokerUserName;

@Value("${brokerpassword")
private String brokerPassword;

@Bean
public ActiveMQConnectionFactory connectionFactory() {
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
connectionFactory.setBrokerURL(brokerUrl);
if (StringUtils.hasText(brokerUserName)) {
connectionFactory.setUserName(brokerUserName);
}
if (StringUtils.hasText(brokerPassword)) {
connectionFactory.setPassword(brokerPassword);
}
connectionFactory.setTrustAllPackages(true);
return connectionFactory;
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
queuename=${EVENT_QUEUE_NAME:JMS-event-queue}
brokerurl=${JMS_BROKER_URL:tcp://127.0.0.1:61616}
brokerusername=${JMS_BROKER_USERNAME:}
brokerpassword=${JMS_BROKER_PASSWORD:}

spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.username=sa
Expand Down

0 comments on commit 2278ede

Please sign in to comment.