1、下载activeMQ安装包http://activemq.apache.org/download-archives.html
2、修改conf文件下的activemq.xml文件,添加登录验证和networkConnector,如下:
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="broker-2" dataDirectory="${activemq.data}">
<plugins>
<simpleAuthenticationPlugin>
<users>
<authenticationUser username="${activemq.username}" password="${activemq.password}" groups="users,admins"/>
</users>
</simpleAuthenticationPlugin>
</plugins>
<networkConnectors>
<networkConnector uri="static:(tcp://127.0.0.1:61616)" userName="system" password="manager"/>
</networkConnectors>
......
</broker>
用户名和密码在
conf/credentials.properties中
,这个broker-2的tansportConnectors
<transportConnectors>
<!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
<transportConnector name="openwire" uri="tcp://0.0.0.0:61626?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="amqp" uri="amqp://0.0.0.0:5675?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="stomp" uri="stomp://0.0.0.0:61619?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="mqtt" uri="mqtt://0.0.0.0:1886?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="ws" uri="ws://0.0.0.0:61615?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
</transportConnectors>
它的端口号是61626,而broker-1的端口号是61616,由于是在一台机器上模拟两个broker,
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="broker-1" dataDirectory="${activemq.data}">
<plugins>
<simpleAuthenticationPlugin>
<users>
<authenticationUser username="${activemq.username}" password="${activemq.password}" groups="users,admins"/>
</users>
</simpleAuthenticationPlugin>
</