59 lines
3.0 KiB
HTML
59 lines
3.0 KiB
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 JMS Load Balanced Static Clustered Queue 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 Load Balanced Static Clustered Queue 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 a JMS queue deployed on two different nodes. The two nodes are configured to form a cluster
|
||
|
from a <em>static</em> list of nodes.</p>
|
||
|
<p>We then create a consumer on the queue on each node, and we create a producer on only one of the nodes.</p>
|
||
|
<p>We then send some messages via the producer, and we verify that <b>both</b> consumers receive the sent messages
|
||
|
in a round-robin fashion.</p>
|
||
|
<p>In other words, ActiveMQ Artemis <b>load balances</b> the sent messages across all consumers on the cluster</p>
|
||
|
<p>This example uses JNDI to lookup the JMS Queue and ConnectionFactory objects. If you prefer not to use
|
||
|
JNDI, these could be instantiated directly.</p>
|
||
|
<p>Here's the relevant snippet from the server configuration, which tells the server to form a cluster between the two nodes
|
||
|
and to load balance the messages between the nodes.</p>
|
||
|
<pre class="prettyprint">
|
||
|
<code><cluster-connection name="my-cluster">
|
||
|
<address>jms</address>
|
||
|
<connector-ref>netty-connector</connector-ref>
|
||
|
<retry-interval>500</retry-interval>
|
||
|
<use-duplicate-detection>true</use-duplicate-detection>
|
||
|
<message-load-balancing>STRICT</message-load-balancing>
|
||
|
<max-hops>1</max-hops>
|
||
|
<static-connectors>
|
||
|
<connector-ref>server1-connector</connector-ref>
|
||
|
</static-connectors>
|
||
|
</cluster-connection>
|
||
|
</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>
|