中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

ActiveMQ之brokers network集群

發布時間:2020-06-08 06:17:24 來源:網絡 閱讀:1838 作者:乾坤刀 欄目:軟件技術

一、集群配置方式類型

master-slave
<networkConnectors>
  <networkConnector uri="masterslave:(tcp://host1:61616,tcp://host2:61616,tcp://..)"/>
</networkConnectors>
  • uri列表中對應的順序就是MASTER,SLAVE1,SLAVE2...SLAVE;
  • master-slave的作用就是brokers之間的主從,同一時刻只能連接一個broker。通常先連接master,如果master連接不上,則連接slave;
  • brokers之間的消息同步機制是通過<persistenceAdapter>共享的存儲方式來共享數據的,如:jdbc/kahaDB/replicaLevelDB(zookeeper)。同時,brokers之間也是通過獲取數據存儲的訪問權來獲取broker的主導權(即哪個broker激活)。
  • zookeeper做masterslave時,brokers的名字必須一致,否則zookeeper會認為不符合2n+1的規則。
  • masterslave這種配置既可以在activeMQ.xml中配置,也可以在client端使用。通常建議在client使用。雖然master-slave可以提高可用性,但是負載均衡的功能減弱,并且很多時候會浪費slave broker服務器
broker static discover
<networkConnectors>
  <networkConnector uri="static:(tcp://host1:61616,tcp://host2:61617,tcp://..)"/>
</networkConnectors>

表示當前local broker與remote broker(61616/61617)建立的單向網絡連接。即local broker可以將消息傳遞給remote broker,但反過來就不行。duplex="true" 屬性配置可以開啟雙向通信。

broker multicast discover
<networkConnectors>
   <networkConnector uri="multicast://default"/>
</networkConnectors>

<transportConnector uri="tcp://localhost:0" discoveryUri="multicast://default"/>

組播發現會自動發現同網絡中的broker并進行連接通信。注意:必須是同網絡中。
在實際的配置很少這樣配置,因為無法保證哪些brokers建立了連接。對于master-slave配置也不是很好。

dynamicallyIncludedDestinations
<dynamicallyIncludedDestinations>
     <queue physicalName="include.test.foo"/>
     <topic physicalName="include.test.bar"/>
</dynamicallyIncludedDestinations>

當networkConnector中連接的broker有customers時,那么對應的destinations才會傳遞到對應的broker。否則,不傳遞。這中方式對于point-to-point的方式就比較合適。

staticallyIncludedDestinations
<staticallyIncludedDestinations>
     <queue physicalName="always.include.queue"/>
     <topic physicalName="always.include.topic"/>
</staticallyIncludedDestinations>

不管networkConnector中連接的broker有無customers,都會講消息發送到每個broker去。這種方式比較適合topic的消息方式。

excludedDestinations
<excludedDestinations>
     <queue physicalName="exclude.test.foo"/>
     <topic physicalName="exclude.test.bar"/>
</excludedDestinations>

networkConnector中指定某些detination不會發送到remote brokers.

networkConnector中uri的參數
uri="static:(tcp://host1:61616,tcp://host2:61616)?maxReconnectDelay=5000&useExponentialBackOff=false"

initialReconnectDelay:重連的時間間隔。
maxReconnectDelay:最大重連時間。即initialReconnectDelay次數
useExponentialBackOff:一次連接失敗,后面的重連時間是否依次遞增。
backOffMultiplier:當useExponentialBackOff=true,重連時間的間隔的倍數,即initialReconnectDelay
backOffMultiplier

networkConnector屬性配置

name:連接名稱,多個時必須唯一。
dynamicOnly:
decreaseNetworkConsumerPriority:
networkTTL:
messageTTL:
consumerTTL:
conduitSubscriptions:管道訂閱。即一個broker有多個customers,也只會認為是一個customer.
excludedDestinations:
dynamicallyIncludedDestinations:
useVirtualDestSubs:
staticallyIncludedDestinations:
duplex:是否開啟雙工通信
prefetchSize:
suppressDuplicateQueueSubscriptions:
bridgeTempDestinations:
alwaysSyncSend:
staticBridge:靜態連接橋。與staticallyIncludedDestinations聯合使用
userName:networkConnector連接用戶名
password:networkConnector連接密碼

二、集群實例

ActiveMQ之brokers network集群

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

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

玛纳斯县| 榕江县| 巫山县| 涿州市| 石河子市| 定结县| 禹州市| 扬中市| 巴彦淖尔市| 龙里县| 江西省| 屏东市| 宜章县| 新乐市| 沙坪坝区| 长子县| 长沙市| 康保县| 永城市| 青海省| 灌南县| 山东省| 名山县| 丰都县| 囊谦县| 墨脱县| 扶绥县| 德保县| 张家界市| 佛山市| 拜泉县| 安泽县| 泽州县| 平罗县| 秭归县| 嘉荫县| 山阳县| 凤台县| 特克斯县| 温州市| 资兴市|