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必須和配置文件裏的一致,否則會拋出異常.     

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章