All Downloads are FREE. Search and download functionalities are using the official Maven repository.

examples.jms.clustered-standalone.readme.html Maven / Gradle / Ivy

The newest version!

  
    JMS Clustered Stand-alone Example
    
    
    
  
  
     

JMS Clustered Stand-alone Example

This example demonstrates a JMS Topic deployed on three different nodes. The three nodes are configured to form a cluster.

Subscribers for the topic are created on each node, and a producer is created on only one of the nodes.

Some messages are sent by the producer, and we verify that all subscribers receive all the sent messages.

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:

     <cluster-connection name="my-cluster">
        <address>jms</address>
        <discovery-group-ref discovery-group-name="dg-group1"/>
     </cluster-connection>
     
     

Example step-by-step

To run the example, simply type ./build.sh (or build.bat on windows) from this directory. This will automatically start the 3 cluster nodes, each with its specific configuration.

To start the tests manually, the following steps are:

  • create 4 terminals (3 for the servers and 1 for the example client)
  • in the first terminal, go to the bin directory and start the first server (with default configuration):
    ./run.sh ../config/stand-alone/clustered
  • in the second terminal, start the second server:
    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
  • in the third terminal, start the third server (with default configuration):
    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
  • finally, in the fourth terminal, start the example
    ./build.sh runRemote (or build.bat runRemote on windows)

    The example connects to the three cluster nodes using JNDI (which are retrieved from server0, server1, and server2' s JNDI properties file). The JNDI ports were specified using the environment property jnp.port (or 1098 by default) when starting the 3 cluster nodes.

    For a description of the example code, please read the clustered-topic example which is very similar (it has 2 nodes while this example has 3 nodes).





© 2015 - 2025 Weber Informatics LLC | Privacy Policy