标签:节点 密码 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>
标签:节点 密码 factor nec let admin activemq nfa 生产者
原文地址:https://www.cnblogs.com/nihaorz/p/13030428.html