activemq-artemis/examples/features/clustered/queue-message-redistribution
Martyn Taylor 057047499b [maven-release-plugin] prepare release 2.0.0 2017-03-10 11:25:47 +00:00
..
src/main ARTEMIS-785 - update examples to new addressing model 2016-12-15 13:36:23 +00:00
pom.xml [maven-release-plugin] prepare release 2.0.0 2017-03-10 11:25:47 +00:00
readme.html renaming broker-features -> features on examples 2015-08-13 00:11:56 -04:00

readme.html

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->

<html>
  <head>
    <title>ActiveMQ Artemis Message Redistribution 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>Message Redistribution Example</h1>

     <pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre>


     <p>This example demonstrates message redistribution between queues with the same name deployed in different
     nodes of a cluster.</p>
     <p>As demontrated in the clustered queue example, if queues with the same name are deployed on different nodes of
     a cluster, ActiveMQ Artemis can be configured to load balance messages between the nodes on the server side.</p>
     <p>However, if the consumer(s) on a particular node are closed, then messages in the queue at that node can
     appear to be stranded, since they have no local consumers.</p>
     <p>If this is undesirable, ActiveMQ Artemis can be configured to <b>redistribute</b> messages from the node
     with no consumers, to nodes where there are consumers. If the consumers have JMS selectors set on them, then they
     will only be redistributed to nodes with consumers whose selectors match.</p>
     <p>By default, message redistribution is disabled, but can be enabled by specifying some AddressSettings configuration
     in either <code>activemq-queues.xml</code> or <code>broker.xml</code></p>
     <p>Setting <code>redistribution-delay</code> to <code>0</code> will cause redistribution to occur immediately
     once there are no more matching consumers on a particular queue instance. Setting it to a positive value > 0 specifies
     a delay in milliseconds before attempting to redistribute. The delay is useful in the case that another consumer is
     likely to be created on the queue, to avoid unnecessary redistribution.</p>
     <p>Here's the relevant snippet from the <code>activemq-queues.xml</code> configuration, which tells the server
     to use a redistribution delay of <code>0</code> on any jms queues, i.e. any queues whose name starts with
     <code>jms.</code></p>
     <pre class="prettyprint">
     <code>
  &lt;address-setting match="jms.#"&gt;
      &lt;redistribution-delay&gt;0&lt;/redistribution-delay&gt;
   &lt;/address-setting&gt;
   </code>
     </pre>
     <p>For more information on ActiveMQ Artemis load balancing, and clustering in general, please see the clustering
     section of the user manual.</p>
  </body>
</html>