ActiveMQ配置用户认证信息
以 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>
相关推荐
胡献根 2020-07-18
胡献根 2020-07-05
jiangtie 2020-06-10
onlylixiaobei 2020-06-09
方新德 2020-05-31
Java高知 2020-05-20
Java高知 2020-05-08
Java高知 2020-05-03
onlylixiaobei 2020-05-02
Java高知 2020-04-22
胡献根 2020-04-22
heweiyabeijing 2020-04-21
方新德 2020-04-20
胡献根 2020-04-10
onlylixiaobei 2020-04-10
方新德 2020-04-08
xuedabao 2020-03-30
heweiyabeijing 2020-03-28