ActiveMQ的认证和授权的简单配置

1.编辑: ${activemq.base}/conf/activemq.xml配置文件,
在<broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.base}/data">节点下添加以下节点
      <plugins>
        <simpleAuthenticationPlugin>
         <users>
          <authenticationUser username="system" password="manager" groups="users,admins"/>
          <authenticationUser username="user" password="password" groups="users"/>
          <authenticationUser username="guest" password="password" groups="guests"/>
         </users>
        </simpleAuthenticationPlugin>
      </plugins>
2.编写JMS客户端程序:
        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(url,username,password);

注意: username 和password必须和配置文件里的一致,否则会抛出异常.     

你可能感兴趣的:(apache,xml,activemq,jms)