【问题标题】:configuring username and password in jndi properties for ActiveMQ在 ActiveMQ 的 jndi 属性中配置用户名和密码
【发布时间】:2016-08-15 06:28:38
【问题描述】:

我有下面的 spring 配置来连接 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 的文档中没有提到这一点

【问题讨论】:

  • 作为 JNDI 创建的一部分,肯定在服务器上配置了密码。

标签: spring activemq jndi


【解决方案1】:

如果你使用 jndi InitialContext 我想你会失去 spring 的力量来配置工厂...... 但是你可以加载这些属性,比如 pwd 或 user 或者像这样的属性文件中的任何属性,如果这是你需要的

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

【讨论】:

    猜你喜欢
    • 2018-02-07
    • 2019-11-24
    • 2019-02-23
    • 1970-01-01
    • 2015-04-11
    • 1970-01-01
    • 1970-01-01
    • 2019-05-08
    • 2011-08-14
    相关资源
    最近更新 更多