HornetQ Deploying a Distributed Topic: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(9 intermediate revisions by the same user not shown)
Line 24: Line 24:


At this point, the topic is deployed ''locally'' on all three nodes. Topic subscriptions will only receive messages sent to the topic on the node the subscription was established on.
At this point, the topic is deployed ''locally'' on all three nodes. Topic subscriptions will only receive messages sent to the topic on the node the subscription was established on.
The name of the topic is important, as we will configure cluster connections to only handle messages sent to the HornetQ core address associated with the topic ("jms.topic.novaordis"). For more details on the relationship between HornetQ core queues, addresses and JMS topics, see [[WildFly_HornetQ-Based_Messaging_Subsystem_Concepts#Address|HornetQ Address]].


=Configure the Cluster Connection on All Nodes=
=Configure the Cluster Connection on All Nodes=


<blockquote style="background-color: Gold; border: solid thin Goldenrod;">
<blockquote style="background-color: Gold; border: solid thin Goldenrod;">
:Cluster connections are unidirectional. For bi-directional propagation of messages between two nodes, two different cluster connections, each connection in an opposite direction, must be established between those two nodes.<br>
:<br>Cluster connections are unidirectional. For bi-directional propagation of messages between two nodes, two different cluster connections, each connection in an opposite direction, must be established between those two nodes.<br><br>
</blockquote>
 
<blockquote style="background-color: Gold; border: solid thin Goldenrod;">
:<br>Note the cluster connection <tt><address></tt> value, it limits the messages handled by the cluster connection only to those sent to the topic.<br><br>
</blockquote>
</blockquote>
==Node n1 Configuration==


Deploy the cluster connection that will distribute topic messages among nodes.  
Deploy the cluster connection that will distribute topic messages among nodes.  


For the node "n1", the configuration is similar to the following example. For n2 and n2, similar configurations should be applied:
For the node "n1", the configuration is similar to the following example. For n2 and n2, symmetric configurations should be applied:


<pre>
<pre>
Line 51: Line 59:


       <cluster-connections>
       <cluster-connections>
         <cluster-connection name="n1-to-n2">
         <cluster-connection name="n1-to-n2">
           <address>jms</address>
           <address>jms.topic.novaordis</address>
           <connector-ref>netty</connector-ref>
           <connector-ref>netty</connector-ref>
           <retry-interval>500</retry-interval>
           <retry-interval>500</retry-interval>
Line 60: Line 69:
           <static-connectors>
           <static-connectors>
             <connector-ref>n2</connector-ref>
             <connector-ref>n2</connector-ref>
          </static-connectors>
        </cluster-connection>
        <cluster-connection name="n1-to-n3">
          <address>jms.topic.novaordis</address>
          <connector-ref>netty</connector-ref>
          <retry-interval>500</retry-interval>
          <use-duplicate-detection>true</use-duplicate-detection>
          <forward-when-no-consumers>true</forward-when-no-consumers>
          <max-hops>1</max-hops>
          <static-connectors>
             <connector-ref>n3</connector-ref>
             <connector-ref>n3</connector-ref>
           </static-connectors>
           </static-connectors>
         </cluster-connection>
         </cluster-connection>
       </cluster-connections>
       </cluster-connections>
     </hornetq-server>
     </hornetq-server>
   </subsystem>
   </subsystem>
Line 76: Line 98:
     <outbound-socket-binding name="n3-binding">
     <outbound-socket-binding name="n3-binding">
       <remote-destination host="n3-host" port="5445"/>
       <remote-destination host="n3-host" port="5445"/>
    </outbound-socket-binding>
  </socket-binding-group>
</server>
</pre>
==Node n2 Configuration==
Deploy the cluster connection that will distribute topic messages among nodes.
<pre>
<server>
  ...
  <subsystem xmlns="urn:jboss:domain:messaging:1.4">
    <hornetq-server>
      ...
      <connectors>
        ...
        <netty-connector name="n1" socket-binding="n1-binding"/>
        <netty-connector name="n3" socket-binding="n3-binding"/>
      </connectors>
      ...
      <cluster-connections>
        <cluster-connection name="n2-to-n1">
          <address>jms.topic.novaordis</address>
          <connector-ref>netty</connector-ref>
          <retry-interval>500</retry-interval>
          <use-duplicate-detection>true</use-duplicate-detection>
          <forward-when-no-consumers>true</forward-when-no-consumers>
          <max-hops>1</max-hops>
          <static-connectors>
            <connector-ref>n1</connector-ref>
          </static-connectors>
        </cluster-connection>
        <cluster-connection name="n2-to-n3">
          <address>jms.topic.novaordis</address>
          <connector-ref>netty</connector-ref>
          <retry-interval>500</retry-interval>
          <use-duplicate-detection>true</use-duplicate-detection>
          <forward-when-no-consumers>true</forward-when-no-consumers>
          <max-hops>1</max-hops>
          <static-connectors>
            <connector-ref>n3</connector-ref>
          </static-connectors>
        </cluster-connection>
      </cluster-connections>
    </hornetq-server>
  </subsystem>
  ...
  <socket-binding-group ...>
    ...
    <outbound-socket-binding name="n1-binding">
      <remote-destination host="n1-host" port="5445"/>
    </outbound-socket-binding>
    <outbound-socket-binding name="n3-binding">
      <remote-destination host="n3-host" port="5445"/>
    </outbound-socket-binding>
  </socket-binding-group>
</server>
</pre>
==Node n3 Configuration==
Deploy the cluster connection that will distribute topic messages among nodes.
<pre>
<server>
  ...
  <subsystem xmlns="urn:jboss:domain:messaging:1.4">
    <hornetq-server>
      ...
      <connectors>
        ...
        <netty-connector name="n1" socket-binding="n1-binding"/>
        <netty-connector name="n2" socket-binding="n2-binding"/>
      </connectors>
      ...
      <cluster-connections>
        <cluster-connection name="n3-to-n1">
          <address>jms.topic.novaordis</address>
          <connector-ref>netty</connector-ref>
          <retry-interval>500</retry-interval>
          <use-duplicate-detection>true</use-duplicate-detection>
          <forward-when-no-consumers>true</forward-when-no-consumers>
          <max-hops>1</max-hops>
          <static-connectors>
            <connector-ref>n1</connector-ref>
          </static-connectors>
        </cluster-connection>
        <cluster-connection name="n3-to-n2">
          <address>jms.topic.novaordis</address>
          <connector-ref>netty</connector-ref>
          <retry-interval>500</retry-interval>
          <use-duplicate-detection>true</use-duplicate-detection>
          <forward-when-no-consumers>true</forward-when-no-consumers>
          <max-hops>1</max-hops>
          <static-connectors>
            <connector-ref>n2</connector-ref>
          </static-connectors>
        </cluster-connection>
      </cluster-connections>
    </hornetq-server>
  </subsystem>
  ...
  <socket-binding-group ...>
    ...
    <outbound-socket-binding name="n1-binding">
      <remote-destination host="n1-host" port="5445"/>
    </outbound-socket-binding>
    <outbound-socket-binding name="n2-binding">
      <remote-destination host="n2-host" port="5445"/>
     </outbound-socket-binding>
     </outbound-socket-binding>
   </socket-binding-group>
   </socket-binding-group>

Latest revision as of 03:00, 25 May 2016

Internal

Overview

This article explains how to deploy a distributed topic - meaning that messages are internally distributed amongst the HornetQ nodes that have the topic deployed on them. The underlying cluster connection that does the internal message distribution is configured to only handle messages destined to the specific topic we're distributing, maintaining all other destinations isolated.

The example assumes three nodes (n1, n2 and n3).

Deploy the Topic on All Nodes

Deploy the topic on all nodes. Use the usual declaration:

<jms-destinations>
  ...
  <jms-topic name="novaordis">
    <entry name="topic/novaordis"/>
    <entry name="java:jboss/exported/topic/novaordis"/>
  </jms-topic>
</jms-destinations>

At this point, the topic is deployed locally on all three nodes. Topic subscriptions will only receive messages sent to the topic on the node the subscription was established on.

The name of the topic is important, as we will configure cluster connections to only handle messages sent to the HornetQ core address associated with the topic ("jms.topic.novaordis"). For more details on the relationship between HornetQ core queues, addresses and JMS topics, see HornetQ Address.

Configure the Cluster Connection on All Nodes


Cluster connections are unidirectional. For bi-directional propagation of messages between two nodes, two different cluster connections, each connection in an opposite direction, must be established between those two nodes.


Note the cluster connection <address> value, it limits the messages handled by the cluster connection only to those sent to the topic.

Node n1 Configuration

Deploy the cluster connection that will distribute topic messages among nodes.

For the node "n1", the configuration is similar to the following example. For n2 and n2, symmetric configurations should be applied:

<server>
  ...

  <subsystem xmlns="urn:jboss:domain:messaging:1.4">
    <hornetq-server>
      ...
      <connectors>
        ...
        <netty-connector name="n2" socket-binding="n2-binding"/>
        <netty-connector name="n3" socket-binding="n3-binding"/>
      </connectors>

      ...

      <cluster-connections>

        <cluster-connection name="n1-to-n2">
          <address>jms.topic.novaordis</address>
          <connector-ref>netty</connector-ref>
          <retry-interval>500</retry-interval>
          <use-duplicate-detection>true</use-duplicate-detection>
          <forward-when-no-consumers>true</forward-when-no-consumers>
          <max-hops>1</max-hops>
          <static-connectors>
            <connector-ref>n2</connector-ref>
           </static-connectors>
         </cluster-connection>

         <cluster-connection name="n1-to-n3">
          <address>jms.topic.novaordis</address>
          <connector-ref>netty</connector-ref>
          <retry-interval>500</retry-interval>
          <use-duplicate-detection>true</use-duplicate-detection>
          <forward-when-no-consumers>true</forward-when-no-consumers>
          <max-hops>1</max-hops>
          <static-connectors>
            <connector-ref>n3</connector-ref>
           </static-connectors>
         </cluster-connection>

       </cluster-connections>

    </hornetq-server>
  </subsystem>

  ...

  <socket-binding-group ...>
    ...
    <outbound-socket-binding name="n2-binding">
      <remote-destination host="n2-host" port="5445"/>
    </outbound-socket-binding>
    <outbound-socket-binding name="n3-binding">
      <remote-destination host="n3-host" port="5445"/>
    </outbound-socket-binding>
  </socket-binding-group>

</server>

Node n2 Configuration

Deploy the cluster connection that will distribute topic messages among nodes.

<server>
  ...

  <subsystem xmlns="urn:jboss:domain:messaging:1.4">
    <hornetq-server>
      ...
      <connectors>
        ...
        <netty-connector name="n1" socket-binding="n1-binding"/>
        <netty-connector name="n3" socket-binding="n3-binding"/>
      </connectors>

      ...

      <cluster-connections>

        <cluster-connection name="n2-to-n1">
          <address>jms.topic.novaordis</address>
          <connector-ref>netty</connector-ref>
          <retry-interval>500</retry-interval>
          <use-duplicate-detection>true</use-duplicate-detection>
          <forward-when-no-consumers>true</forward-when-no-consumers>
          <max-hops>1</max-hops>
          <static-connectors>
            <connector-ref>n1</connector-ref>
           </static-connectors>
         </cluster-connection>

         <cluster-connection name="n2-to-n3">
          <address>jms.topic.novaordis</address>
          <connector-ref>netty</connector-ref>
          <retry-interval>500</retry-interval>
          <use-duplicate-detection>true</use-duplicate-detection>
          <forward-when-no-consumers>true</forward-when-no-consumers>
          <max-hops>1</max-hops>
          <static-connectors>
            <connector-ref>n3</connector-ref>
           </static-connectors>
         </cluster-connection>

       </cluster-connections>

    </hornetq-server>
  </subsystem>

  ...

  <socket-binding-group ...>
    ...
    <outbound-socket-binding name="n1-binding">
      <remote-destination host="n1-host" port="5445"/>
    </outbound-socket-binding>
    <outbound-socket-binding name="n3-binding">
      <remote-destination host="n3-host" port="5445"/>
    </outbound-socket-binding>
  </socket-binding-group>

</server>

Node n3 Configuration

Deploy the cluster connection that will distribute topic messages among nodes.

<server>
  ...

  <subsystem xmlns="urn:jboss:domain:messaging:1.4">
    <hornetq-server>
      ...
      <connectors>
        ...
        <netty-connector name="n1" socket-binding="n1-binding"/>
        <netty-connector name="n2" socket-binding="n2-binding"/>
      </connectors>

      ...

      <cluster-connections>

        <cluster-connection name="n3-to-n1">
          <address>jms.topic.novaordis</address>
          <connector-ref>netty</connector-ref>
          <retry-interval>500</retry-interval>
          <use-duplicate-detection>true</use-duplicate-detection>
          <forward-when-no-consumers>true</forward-when-no-consumers>
          <max-hops>1</max-hops>
          <static-connectors>
            <connector-ref>n1</connector-ref>
           </static-connectors>
         </cluster-connection>

         <cluster-connection name="n3-to-n2">
          <address>jms.topic.novaordis</address>
          <connector-ref>netty</connector-ref>
          <retry-interval>500</retry-interval>
          <use-duplicate-detection>true</use-duplicate-detection>
          <forward-when-no-consumers>true</forward-when-no-consumers>
          <max-hops>1</max-hops>
          <static-connectors>
            <connector-ref>n2</connector-ref>
           </static-connectors>
         </cluster-connection>

       </cluster-connections>

    </hornetq-server>
  </subsystem>

  ...

  <socket-binding-group ...>
    ...
    <outbound-socket-binding name="n1-binding">
      <remote-destination host="n1-host" port="5445"/>
    </outbound-socket-binding>
    <outbound-socket-binding name="n2-binding">
      <remote-destination host="n2-host" port="5445"/>
    </outbound-socket-binding>
  </socket-binding-group>

</server>