您好,登錄后才能下訂單哦!
<networkConnectors>
<networkConnector uri="masterslave:(tcp://host1:61616,tcp://host2:61616,tcp://..)"/>
</networkConnectors>
<networkConnectors>
<networkConnector uri="static:(tcp://host1:61616,tcp://host2:61617,tcp://..)"/>
</networkConnectors>
表示當(dāng)前l(fā)ocal broker與remote broker(61616/61617)建立的單向網(wǎng)絡(luò)連接。即local broker可以將消息傳遞給remote broker,但反過來就不行。duplex="true" 屬性配置可以開啟雙向通信。
<networkConnectors>
<networkConnector uri="multicast://default"/>
</networkConnectors>
<transportConnector uri="tcp://localhost:0" discoveryUri="multicast://default"/>
組播發(fā)現(xiàn)會自動發(fā)現(xiàn)同網(wǎng)絡(luò)中的broker并進(jìn)行連接通信。注意:必須是同網(wǎng)絡(luò)中。
在實際的配置很少這樣配置,因為無法保證哪些brokers建立了連接。對于master-slave配置也不是很好。
<dynamicallyIncludedDestinations>
<queue physicalName="include.test.foo"/>
<topic physicalName="include.test.bar"/>
</dynamicallyIncludedDestinations>
當(dāng)networkConnector中連接的broker有customers時,那么對應(yīng)的destinations才會傳遞到對應(yīng)的broker。否則,不傳遞。這中方式對于point-to-point的方式就比較合適。
<staticallyIncludedDestinations>
<queue physicalName="always.include.queue"/>
<topic physicalName="always.include.topic"/>
</staticallyIncludedDestinations>
不管networkConnector中連接的broker有無customers,都會講消息發(fā)送到每個broker去。這種方式比較適合topic的消息方式。
<excludedDestinations>
<queue physicalName="exclude.test.foo"/>
<topic physicalName="exclude.test.bar"/>
</excludedDestinations>
networkConnector中指定某些detination不會發(fā)送到remote brokers.
uri="static:(tcp://host1:61616,tcp://host2:61616)?maxReconnectDelay=5000&useExponentialBackOff=false"
initialReconnectDelay:重連的時間間隔。
maxReconnectDelay:最大重連時間。即initialReconnectDelay次數(shù)
useExponentialBackOff:一次連接失敗,后面的重連時間是否依次遞增。
backOffMultiplier:當(dāng)useExponentialBackOff=true,重連時間的間隔的倍數(shù),即initialReconnectDelaybackOffMultiplier
name:連接名稱,多個時必須唯一。
dynamicOnly:
decreaseNetworkConsumerPriority:
networkTTL:
messageTTL:
consumerTTL:
conduitSubscriptions:管道訂閱。即一個broker有多個customers,也只會認(rèn)為是一個customer.
excludedDestinations:
dynamicallyIncludedDestinations:
useVirtualDestSubs:
staticallyIncludedDestinations:
duplex:是否開啟雙工通信
prefetchSize:
suppressDuplicateQueueSubscriptions:
bridgeTempDestinations:
alwaysSyncSend:
staticBridge:靜態(tài)連接橋。與staticallyIncludedDestinations聯(lián)合使用
userName:networkConnector連接用戶名
password:networkConnector連接密碼
broker-master
<networkConnectors>
<networkConnector name="connector_master_slave" uri="static:(tcp://localhost:61618,tcp://localhost:61619)"
userName="admin" password="admin123"/>
<networkConnector name="connector_brokers" uri="static:(tcp://localhost:61620,tcp://localhost:61621)" userName="admin" password="admin123">
<dynamicallyIncludedDestinations>
<queue physicalName=">"/>
</dynamicallyIncludedDestinations>
<staticallyIncludedDestinations>
<topic physicalName=">"/>
</staticallyIncludedDestinations>
</networkConnector>
</networkConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:61617?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
broker-slave01
<networkConnectors>
<networkConnector name="connector_master_slave" uri="static:(tcp://localhost:61617,tcp://localhost:61619)" userName="admin" password="admin123"/>
<networkConnector name="connector_brokers" uri="static:(tcp://localhost:61620,tcp://localhost:61621)" userName="admin" password="admin123">
<dynamicallyIncludedDestinations>
<queue physicalName=">"/>
</dynamicallyIncludedDestinations>
<staticallyIncludedDestinations>
<topic physicalName=">"/>
</staticallyIncludedDestinations>
</networkConnector>
</networkConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:61618?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
broker-slave02
<networkConnectors>
<networkConnector name="connector_master_slave"
uri="static:(tcp://localhost:61617,tcp://localhost:61618)" userName="admin" password="admin123"/>
<networkConnector name="connector_brokers" uri="static:(tcp://localhost:61620,tcp://localhost:61621)" userName="admin" password="admin123">
<dynamicallyIncludedDestinations>
<queue physicalName=">"/>
</dynamicallyIncludedDestinations>
<staticallyIncludedDestinations>
<topic physicalName=">"/>
</staticallyIncludedDestinations>
</networkConnector>
</networkConnectors>
broker-cluster01
<networkConnectors>
<networkConnector uri="static:(tcp://localhost:61621)" duplex="false" name="connector_broker_normal" userName="admin" password="admin123">
<dynamicallyIncludedDestinations>
<queue physicalName=">" />
<topic physicalName=">" />
</dynamicallyIncludedDestinations>
</networkConnector>
</networkConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:61620?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
broker-cluster02
<networkConnectors>
<networkConnector uri="static:(tcp://localhost:61620)" duplex="false" name="connector_broker_normal" userName="admin" password="admin123">
<dynamicallyIncludedDestinations>
<queue physicalName=">" />
<topic physicalName=">" />
</dynamicallyIncludedDestinations>
</networkConnector>
</networkConnectors>
<transportConnector name="openwire"uri="tcp://0.0.0.0:61621?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
brokers的安全配置
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>file:${activemq.conf}/credentials.properties</value>
</property>
</bean>
<plugins>
<simpleAuthenticationPlugin>
<users>
<authenticationUser username="${activemq.username}" password="${activemq.password}" groups="admins"/>
</users>
</simpleAuthenticationPlugin>
<authorizationPlugin>
<map>
<authorizationMap>
<authorizationEntries>
<authorizationEntry queue=">" read="admins" write="admins" admin="admins" />
<authorizationEntry topic=">" read="admins" write="admins" admin="admins"/>
</authorizationEntries>
<tempDestinationAuthorizationEntry>
<tempDestinationAuthorizationEntry read="admins" write="admins" admin="admins"/>
</tempDestinationAuthorizationEntry>
</authorizationMap>
</map>
</authorizationPlugin>
</plugins>
參考文檔:
http://activemq.apache.org/networks-of-brokers.html
http://shift-alt-ctrl.iteye.com/blog/2070531
https://www.cnblogs.com/shihaiming/p/6018916.html
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。