在ActiveMQ的jndi属性中配置用户名和密码

时间:2016-08-10 09:03:39

标签: spring activemq jndi

我有以下弹簧配置连接到ActiveMQ:

<bean id="connectionFactory"   class="org.apache.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL" value="tcp://10.3.2.3:61616" />
    <property name="userName"
        value="Platform.user.consumer" />
    <property name="password" value="Test123"></property>
    <property name="redeliveryPolicy">
        <bean class="org.apache.activemq.RedeliveryPolicy">
            <property name="maximumRedeliveries" value="7" />
        </bean>
    </property>
</bean>

我想在外部属性文件中配置属性,并希望使用JNDI加载。我在以下属性中配置了JNDI参数:

#Active MQ properties
  java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory
  java.naming.provider.url=tcp://localhost:61616
  connectionFactoryNames=connectionFactory
  #register the queue in the JNDI using the below form
  #queue.[queueName]=
  queue.myQueue=com.inputqueue

如何在属性文件中配置Platform.user.consumerpassword属性。请告诉我,因为Active MQ的文档中没有提到

1 个答案:

答案 0 :(得分:0)

如果你使用jndi InitialContext,我认为你将失去弹簧的力量来配置工厂...... 但是你可以加载像pwd或者用户这样的属性,或者像这样加载属性文件中的任何属性,如果你需要的话

http://docs.spring.io/autorepo/docs/spring-framework/3.2.17.RELEASE/javadoc-api/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.html

像这样,您可以使用$ {password}替换为springcontext.properties中密钥“password”的值“Test123” 例如: 密码= Test123

相关问题