activemq主從和叢集結合的部署方式
阿新 • • 發佈:2019-01-25
Broker-Cluster部署方式中,各個broker通過網路互相連線,並共享queue,提供了2中部署方式:
static Broker-Cluster和Dynamic Broker-Cluster
1).static Broker-Cluster
將ActiveMq拷貝2份,分別命名:apache-activemq-5.10.0_M1,apache-activemq-5.10.0_M2,
下面就是配置activemq,xml:
M1做如下配置:
1 2 3 |
<networkConnectors> <networkConnector
uri= "static:(tcp://localhost:61617)" />
</networkConnectors>
|
1 2 3 |
<transportConnectors>
<transportConnector
name= "openwire" uri= "tcp://0.0.0.0:61616?maximumConnectio
ns=1000&wireFormat.maxFrameSize=104857600" />
</transportConnectors>
|
?
1 2 3 |
<networkConnectors>
<networkConnector
uri= "static:(tcp://localhost:61616)" />
</networkConnectors>
|
1 2 3 |
<transportConnectors> <transportConnector
name= "openwire" uri= "tcp://0.0.0.0:61617?maximumConnectio
ns=1000&wireFormat.maxFrameSize=104857600" />
</transportConnectors>
|
啟動M1和M2,可以看到如下啟動日誌:
可以看到M1和M2,network connection has been established
測試我們還是用上一篇中的Sender和Receiver類,只需要做一點點修改:
Sender類還是連結tcp://localhost:61616,傳送訊息到queue,
Receiver做如下修改:
1 2 3 |
connectionFactory
= new ActiveMQConnectionFactory(
ActiveMQConnection.DEFAULT_USER,
ActiveMQConnection.DEFAULT_PASSWORD, "tcp://localhost:616
|