2015-01-05 07:45:36 -05:00
<!--
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.
-->
2014-10-31 06:20:28 -04:00
< html >
< head >
2015-05-13 06:12:07 -04:00
< title > ActiveMQ Artemis Message Redistribution Example< / title >
2015-08-10 10:41:52 -04:00
< 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 >
2014-10-31 06:20:28 -04:00
< / head >
< body onload = "prettyPrint()" >
< h1 > Message Redistribution Example< / h1 >
2015-08-05 15:33:20 -04:00
< 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 >
2014-10-31 06:20:28 -04:00
< 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
2015-05-13 06:12:07 -04:00
a cluster, ActiveMQ Artemis can be configured to load balance messages between the nodes on the server side.< / p >
2014-10-31 06:20:28 -04:00
< 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 >
2015-05-13 06:12:07 -04:00
< p > If this is undesirable, ActiveMQ Artemis can be configured to < b > redistribute< / b > messages from the node
2014-10-31 06:20:28 -04:00
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
2015-04-29 05:30:31 -04:00
in either < code > activemq-queues.xml< / code > or < code > broker.xml< / code > < / p >
2014-10-31 06:20:28 -04:00
< 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
2015-08-05 15:33:20 -04:00
likely to be created on the queue, to avoid unnecessary redistribution.< / p >
2014-11-19 14:58:44 -05:00
< p > Here's the relevant snippet from the < code > activemq-queues.xml< / code > configuration, which tells the server
2014-10-31 06:20:28 -04:00
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 >
< address-setting match="jms.#">
< redistribution-delay> 0< /redistribution-delay>
< /address-setting>
< / code >
2015-08-05 15:33:20 -04:00
< / pre >
2015-05-13 06:12:07 -04:00
< p > For more information on ActiveMQ Artemis load balancing, and clustering in general, please see the clustering
2015-08-05 15:33:20 -04:00
section of the user manual.< / p >
2014-10-31 06:20:28 -04:00
< / body >
2015-01-05 07:45:36 -05:00
< / html >