码迷,mamicode.com
首页 > 其他好文 > 详细

ActiveMQ配置用户认证信息

时间:2020-06-02 13:10:17      阅读:56      评论:0      收藏:0      [点我收藏+]

标签:节点   密码   factor   nec   let   admin   activemq   nfa   生产者   

以 apache-activemq-5.15.12-bin.tar.gz 为例,修改activemq.xml

在 <broker> 节点内的 <systemUsage> 节点前面新增如下xml片段:

<plugins>
    <simpleAuthenticationPlugin>
        <users>
            <authenticationUser username="gfstack" password="gfstack" groups="users, admins" />
        </users>
    </simpleAuthenticationPlugin>
</plugins>

重启activemq生效

代码修改:

在定义activemq连接池的时候添加用户密码信息即可,示例如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">

<beans>
    <!-- 配置生产者连接池 -->
    <bean id="producerConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory"
        destroy-method="stop">
        <property name="connectionFactory">
            <bean class="org.apache.activemq.ActiveMQConnectionFactory">
                <property name="brokerURL">
                    <value>${activemq.url}</value>
                </property>
                <property name="userName">
                    <value>gfstack</value>
                </property>
                <property name="password">
                    <value>gfstack</value>
                </property>
            </bean>
        </property>
        <property name="maxConnections" value="${producer.maxConnections}"></property>
        <property name="maximumActiveSessionPerConnection" value="${producer.maximumActiveSessionPerConnection}"></property>
        <property name="idleTimeout" value="${producer.idleTimeout}"></property>
    </bean>
    
    <!-- 配置消费者连接池 -->
    <bean id="consumerConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory"
        destroy-method="stop">
        <property name="connectionFactory">
            <bean class="org.apache.activemq.ActiveMQConnectionFactory">
                <property name="brokerURL">
                    <value>${activemq.url}</value>
                </property>
                <property name="userName">
                    <value>gfstack</value>
                </property>
                <property name="password">
                    <value>gfstack</value>
                </property>
            </bean>
        </property>
        <property name="maxConnections" value="${consumer.maxConnections}"></property>
        <property name="maximumActiveSessionPerConnection" value="${consumer.maximumActiveSessionPerConnection}"></property>
        <property name="idleTimeout" value="${consumer.idleTimeout}"></property>
    </bean>
</beans>

 

ActiveMQ配置用户认证信息

标签:节点   密码   factor   nec   let   admin   activemq   nfa   生产者   

原文地址:https://www.cnblogs.com/nihaorz/p/13030428.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!