Laze

If I rest I rust !

  博客园  :: 首页  :: 新随笔  ::  ::  :: 管理

1、设置ActiveMQ的访问密码,以提高ActiveMQ的安全性

2、在ActiveMQ的conf目录的activemq.xml中添加账号密码

      2.1  添加的代码如下

<!-- 添加访问ActiveMQ的账号密码 -->

<plugins>
  <simpleAuthenticationPlugin>
    <users>
      <authenticationUser username="**001" password="123" groups="users,admins"/>
    </users>
  </simpleAuthenticationPlugin>
</plugins>

 


      2.2  添加在active.xml的位置如下

 

 

3、利用设置的账号,密码,访问ActiveMQ

// 1、建立ConnectionFactory工厂对象,需要填入用户名,密码,以及连接的地址
// 仅使用默认。端口号为"tcp://localhost:61616"

  
//ActiveMq 的默认用户名
private static final String USERNAME = "**001" /*ActiveMQConnection.DEFAULT_USER*/;
//ActiveMq 的默认登录密码
private static final String PASSWORD = "123456" /*ActiveMQConnection.DEFAULT_PASSWORD*/;
//ActiveMQ 的链接地址
private static final String BROKEN_URL = "tcp://47.91.161.285:10112";

//创建一个链接工厂 connectionFactory = new ActiveMQConnectionFactory(USERNAME,PASSWORD,BROKEN_URL); //从工厂中创建一个链接 connection = connectionFactory.createConnection(); //开启链接 connection.start();

 

posted on 2018-11-12 21:11  CollinTsui  阅读(1704)  评论(0)    收藏  举报