2016年1月28日星期四

ActiveMQ_008:Network Connector 配置参数conduitSubscriptions的含义(摘录+整理)

1. 部署拓扑图如下:
Broker-1 单向转发消息到 Broker-2 和 Broker-3。
Producer 发送消息到Broker-1的Queue:moo.bar。
Consumer-1监听Broker-2的Queue:moo.bar。
Consumer-2 和 Consumer-3 监听Broker-3的Queue:moo.bar。



2. Broker-1上的activemq.xml的networkConnectors配置片段如下:
<networkConnectors>
    <networkConnector
      name="Q:broker1->broker2"
      uri="static:(tcp://localhost:61626)"
      duplex="false"
      decreaseNetworkConsumerPriority="true"
      networkTTL="2"
      dynamicOnly="true">
      <excludedDestinations>
         <topic physicalName=">" />
      </excludedDestinations>
    </networkConnector>

    <networkConnector
       name="Q:broker1->broker3"
       uri="static:(tcp://localhost:61636)"
       duplex="false"
       decreaseNetworkConsumerPriority="true"
       networkTTL="2"
       dynamicOnly="true">
       <excludedDestinations>
            <topic physicalName=">" />
       </excludedDestinations>
    </networkConnector>
</networkConnectors>

3. 启动 Broker-1、Broker-2、Broker-3

4. 启动 Consumer-1、Consumer-2、Consumer-3
(1)在Broker-2的Console上,可以看到1个Consumer:Consumer-1。
(2)在Broker-3的Console上,可以看到2个Consumer:Consumer-2和Consumer-3。
(3)在Broker-1的Console上,可以看到2个Consumer:Broker-2和Broker-3。
这是因为默认情况下,conduitSubscriptions="true",从Broker-1的角度看,Consumer-2和Consumer-3被看做成1个Consumer。
在Broker-1的Console上,查看Queue的详细信息:


消息的分配如下图:
5. 修改Broker-1上的activemq.xml的networkConnectors配置片段如下:
<networkConnectors>
    <networkConnector
      name="Q:broker1->broker2"
      uri="static:(tcp://localhost:61626)"
      duplex="false"
      decreaseNetworkConsumerPriority="true"
      networkTTL="2"
      conduitSubscriptions="false"
      dynamicOnly="true">
      <excludedDestinations>
         <topic physicalName=">" />
      </excludedDestinations>
    </networkConnector>

    <networkConnector
       name="Q:broker1->broker3"
       uri="static:(tcp://localhost:61636)"
       duplex="false"
       decreaseNetworkConsumerPriority="true"
       networkTTL="2"
       conduitSubscriptions="false"
       dynamicOnly="true">
       <excludedDestinations>
            <topic physicalName=">" />
       </excludedDestinations>
    </networkConnector>
</networkConnectors>

6. 重新启动Broker-1、Broker-2、Broker-3

7. 重新启动Proucer、Consumer-1、Consumer-2Consumer-3

消息的分配如下图:


在Broker-1的Console上,查看Queue的详细信息:

参考文献:
1. http://akuntamukkala.blogspot.com/2014/02/activemq-network-of-brokers-explained.html
2. http://akuntamukkala.blogspot.com/2014/02/activemq-network-of-brokers-explained_28.html
3. http://akuntamukkala.blogspot.com/2014/03/activemq-network-of-brokers-explained.html
4. http://akuntamukkala.blogspot.com/2014/03/activemq-network-of-brokers-explained_26.html
5. http://akuntamukkala.blogspot.com/2014/05/activemq-network-of-brokers-explained.html

没有评论: