HornetQ Deploying a Distributed Topic: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 36: Line 36:


<pre>
<pre>
<server>
  ...
   <subsystem xmlns="urn:jboss:domain:messaging:1.4">
   <subsystem xmlns="urn:jboss:domain:messaging:1.4">
     <hornetq-server>
     <hornetq-server>

Revision as of 02:25, 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.

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.

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:

<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</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>
            <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>