mirror of
https://github.com/apache/activemq-artemis.git
synced 2025-02-07 10:38:44 +00:00
<html> <head> <title>JMS Clustered Stand-alone Example</title> <link rel="stylesheet" type="text/css" href="../common/common.css" /> <link rel="stylesheet" type="text/css" href="../common/prettify.css" /> <script type="text/javascript" src="../common/prettify.js"></script> </head> <body onload="prettyPrint()"> <h1>JMS Clustered Stand-alone Example</h1> <p>This example demonstrates a JMS Topic deployed on three different nodes. The three nodes are configured to form a cluster.</p> <p>Subscribers for the topic are created on each node, and a producer is created on only one of the nodes.</p> <p>Some messages are sent by the producer, and we verify that <strong>all</strong> subscribers receive all the sent messages.</p> <p>This example uses HornetQ's default stand-alone clustered configuration. The relevant snippet from the server configuration, which tells the servers to form a cluster between the three nodes and to load balance the messages between the nodes is:</p> <pre class="prettyprint"> <code><cluster-connection name="my-cluster"> <address>jms</address> <discovery-group-ref discovery-group-name="dg-group1"/> </cluster-connection> </code> </pre> <h2>Example step-by-step</h2> <p><i>To run the example, simply type <code>mvn verify</code> from this directory</i>. This will automatically start the 3 cluster nodes, each with its specific configuration.</p> <p>To start the tests <em>manually</em>, the following steps are:</p> <ul> <li>create 4 terminals (3 for the servers and 1 for the example client)</li> <li>in the first terminal, go to the <code>bin</code> directory and start the first server (with default configuration): <pre class="prettyprint"><code>./run.sh ../config/stand-alone/clustered</code></pre> <li>in the second terminal, start the second server: <pre class="prettyprint"><code>export CLUSTER_PROPS="-Ddata.dir=../data-server2 -Djnp.port=2099 -Djnp.rmiPort=2098 -Dhornetq.remoting.netty.port=6445 -Dhornetq.remoting.netty.batch.port=6455" ./run.sh ../config/stand-alone/clustered</code></pre> <li>in the third terminal, start the third server (with default configuration): <pre class="prettyprint"><code>export CLUSTER_PROPS="-Ddata.dir=../data-server3 -Djnp.port=3099 -Djnp.rmiPort=3098 -Dhornetq.remoting.netty.port=7445 -Dhornetq.remoting.netty.batch.port=7455" ./run.sh ../config/stand-alone/clustered</code></pre> <li>finally, in the fourth terminal, start the example <pre class="prettyprint"><code>./build.sh runRemote</code> (or <code>build.bat runRemote</code> on windows)</pre> <p>The example connects to the three cluster nodes using JNDI (which are retrieved from <a href="server0/client-jndi.properties">server0</a>, <a href="server1/client-jndi.properties">server1</a>, and <a href="server2/client-jndi.properties">server2</a>' s JNDI properties file). The JNDI ports were specified using the environment property <code>jnp.port</code> (or 1098 by default) when starting the 3 cluster nodes.</p> <p>For a description of the example code, please read the <a href="../clustered-topic/readme.html"> clustered-topic example</a> which is very similar (it has 2 nodes while this example has 3 nodes). </body> </html>