9.2.2. 追加のブローカークラスタートポロジー
ブローカークラスターには、多くの異なるトポロジーで接続できます。AMQ Broker 7 では、対称クラスターおよびチェーンクラスターは最も一般的なものになります。
例: 対称クラスター
完全なメッシュトポロジーでは、各ブローカーはクラスター内の他のすべてのブローカーに接続されます。つまり、クラスター内のブローカーはすべて、他のすべてのブローカーから 2 ホップ以上離れていません。
この例では、動的な検出を使用して、クラスター内のブローカーが相互に検出できるようにします。max-hops を 1 に設定すると、各ブローカーは他のすべてのブローカーに接続されます。
<!-- Clustering configuration -->
<broadcast-groups>
<broadcast-group name="my-broadcast-group">
<group-address>${udp-address:231.7.7.7}</group-address>
<group-port>9876</group-port>
<broadcast-period>100</broadcast-period>
<connector-ref>netty-connector</connector-ref>
</broadcast-group>
</broadcast-groups>
<discovery-groups>
<discovery-group name="my-discovery-group">
<group-address>${udp-address:231.7.7.7}</group-address>
<group-port>9876</group-port>
<refresh-timeout>10000</refresh-timeout>
</discovery-group>
</discovery-groups>
<cluster-connections>
<cluster-connection name="my-cluster">
<connector-ref>netty-connector</connector-ref>
<retry-interval>500</retry-interval>
<use-duplicate-detection>true</use-duplicate-detection>
<message-load-balancing>ON_DEMAND</message-load-balancing>
<max-hops>1</max-hops>
<discovery-group-ref discovery-group-name="my-discovery-group"/>
</cluster-connection>
</cluster-connections>例: チェーンクラスター
チェーンクラスターでは、ブローカーは両端がブローカーの直線状の「チェーン」を形成し、他のすべてのブローカーはチェーンの前のブローカーおよび次のブローカーに接続されます (例: A→B→C)。
この例では、静的検出を使用して、3 つのブローカーをチェーンクラスターに接続します。各ブローカーはチェーン内の次のブローカーに接続され、max-hops は 2 に設定され、メッセージがチェーン全体で流れるようにします。
最初のブローカーは以下のように設定されます。
<connectors>
<connector name="netty-connector">tcp://localhost:61616</connector>
<!-- connector to broker2 -->
<connector name="broker2-connector">tcp://localhost:61716</connector>
</connectors>
<cluster-connections>
<cluster-connection name="my-cluster">
<address>jms</address>
<connector-ref>netty-connector</connector-ref>
<retry-interval>500</retry-interval>
<use-duplicate-detection>true</use-duplicate-detection>
<message-load-balancing>STRICT</message-load-balancing>
<max-hops>2</max-hops>
<static-connectors allow-direct-connections-only="true">
<connector-ref>broker2-connector</connector-ref>
</static-connectors>
</cluster-connection>
</cluster-connections>2 番目のブローカーは以下のように設定されます。
<connectors>
<connector name="netty-connector">tcp://localhost:61716</connector>
<!-- connector to broker3 -->
<connector name="broker3-connector">tcp://localhost:61816</connector>
</connectors>
<cluster-connections>
<cluster-connection name="my-cluster">
<address>jms</address>
<connector-ref>netty-connector</connector-ref>
<retry-interval>500</retry-interval>
<use-duplicate-detection>true</use-duplicate-detection>
<message-load-balancing>STRICT</message-load-balancing>
<max-hops>1</max-hops>
<static-connectors allow-direct-connections-only="true">
<connector-ref>broker3-connector</connector-ref>
</static-connectors>
</cluster-connection>
</cluster-connections>最後に、3 番目のブローカーは以下のように設定されます。
<connectors>
<connector name="netty-connector">tcp://localhost:61816</connector>
</connectors>
<cluster-connections>
<cluster-connection name="my-cluster">
<address>jms</address>
<connector-ref>netty-connector</connector-ref>
<retry-interval>500</retry-interval>
<use-duplicate-detection>true</use-duplicate-detection>
<message-load-balancing>STRICT</message-load-balancing>
<max-hops>0</max-hops>
</cluster-connection>
</cluster-connections>