ARTEMIS-1562 Refactor example documentation

This commit contains these changes:
* Change example documentation to use markdown
* Generate HTML doc based on markdown during release
* Fix XML formatting in some examples
* Repair out-of-date documentation
This commit is contained in:
Justin Bertram 2017-10-24 14:20:37 -05:00 committed by Martyn Taylor
parent 4ad05e1ddb
commit b77cdaf773
447 changed files with 4753 additions and 10312 deletions

1
.gitignore vendored
View File

@ -12,6 +12,7 @@ ratReport.txt
.factorypath .factorypath
**/.editorconfig **/.editorconfig
**/derby.log **/derby.log
examples/**/readme.html
# for native build # for native build
CMakeCache.txt CMakeCache.txt

View File

@ -220,6 +220,7 @@
<exclude>**/target/**</exclude> <exclude>**/target/**</exclude>
<exclude>**/**/*.iml</exclude> <exclude>**/**/*.iml</exclude>
<exclude>**/**/*.dat</exclude> <exclude>**/**/*.dat</exclude>
<exclude>**/**/*.md</exclude>
</excludes> </excludes>
</fileSet> </fileSet>
<!-- Include license and notice files --> <!-- Include license and notice files -->

View File

@ -0,0 +1,2 @@
</body>
</html>

View File

@ -18,18 +18,10 @@ under the License.
--> -->
<html> <html>
<head> <head>
<title>ActiveMQ Artemis JMS Queue Example</title> <title>ActiveMQ Artemis Example</title>
<link rel="stylesheet" type="text/css" href="../../../common/common.css" /> <link rel="stylesheet" type="text/css" href="../../../common/common.css" />
<link rel="stylesheet" type="text/css" href="../../../common/prettify.css" /> <link rel="stylesheet" type="text/css" href="../../../common/prettify.css" />
<script type="text/javascript" src="../../../common/prettify.js"></script> <script type="text/javascript" src="../../../common/prettify.js"></script>
</head> </head>
<body onload="prettyPrint()"> <body onload="prettyPrint()">
<h1>JMS Queue Message Listener for openwire</h1>
<pre>This example will start and stop the server within the example.</pre>
<p>This example shows how to use send messages to a queue, and having these messages recovered from the journal.</p>
</body>
</html>

View File

@ -197,7 +197,23 @@ under the License.
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
</plugin>
</plugins> </plugins>
</build> </build>
<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>markdown-page-generator-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project> </project>

View File

@ -1,49 +0,0 @@
<!--
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 Client-Side Load-Balancing 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 Client-Side Load-Balancing 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 how connnections created from a single JMS Connection factory can be created
to different nodes of the cluster. In other words it demonstrates how ActiveMQ Artemis does <b>client side load balancing</b> of
connections across the cluster.</p>
<p>The particular load-balancing policy can be chosen to be random, round-robin or user-defined. Please see the user
guide for more details of how to configure the specific load-balancing policy. In this example we will use
the default round-robin load balancing policy.</p>
<p>The list of servers over which ActiveMQ Artemis will round-robin the connections can either be specified explicitly
in the connection factory when instantiating it directly, when configuring it on the server or configured
to use UDP discovery to discover the list of servers over which to round-robin. This example will use UDP
discovery to obtain the list.</p>
<p>This example starts three servers which all broadcast their location using UDP discovery. The UDP broadcast configuration
can be seen in the <code>broker.xml</code> file.</p>
<p>A JMS ConnectionFactory is deployed on each server specifying the discovery group that will be used by that
connection factory.</p>
<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>

View File

@ -0,0 +1,15 @@
# JMS Client-Side Load-Balancing Example
To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to create and start the broker manually.
This example demonstrates how connections created from a single JMS Connection factory can be created to different nodes of the cluster. In other words it demonstrates how ActiveMQ Artemis does **client side load balancing** of connections across the cluster.
The particular load-balancing policy can be chosen to be random, round-robin or user-defined. Please see the user guide for more details of how to configure the specific load-balancing policy. In this example we will use the default round-robin load balancing policy.
The list of servers over which ActiveMQ Artemis will round-robin the connections can either be specified explicitly in the connection factory when instantiating it directly, when configuring it on the broker or configured to use UDP discovery to discover the list of servers over which to round-robin. This example will use UDP discovery to obtain the list.
This example starts three servers which all broadcast their location using UDP discovery. The UDP broadcast configuration can be seen in the `broker.xml` file.
A JMS ConnectionFactory is deployed on each broker specifying the discovery group that will be used by that connection factory.
For more information on ActiveMQ Artemis load balancing, and clustering in general, please see the clustering section of the user manual.

View File

@ -155,7 +155,23 @@ under the License.
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
</plugin>
</plugins> </plugins>
</build> </build>
<profiles>
</project> <profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>markdown-page-generator-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -1,65 +0,0 @@
<!--
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 Durable Subscription 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 Durable Subscription 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 clustered JMS durable subscription.
Normally durable subscriptions exist on a single node and can only have one subscriber at any one time,
however, with ActiveMQ Artemis it's possible to create durable subscription instances with the same name and client-id
on different nodes of the cluster, and consume from them simultaneously.
This allows the work of processing messages from a durable subscription to be spread across the cluster in
a similar way to how JMS Queues can be load balanced across the cluster
</p>
<p>In this example we first configure the two nodes to form a cluster, then we then create a durable subscriber
with the same name and client-id on both nodes, 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 the messages are round robin'd between
the two subscription instances. Note that each durable subscription instance with the same name and client-id
<b>does not</b> receive its own copy of the messages. This is because the instances on different nodes form a
single "logical" durable subscription, in the same way multiple JMS Queue instances on different nodes
form a single "local" JMS Queue</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>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>
<p>The cli create method will define this section by default if you use --clustered as a parameter</p>
<pre class="prettyprint">
<code>&lt;cluster-connection name="my-cluster"&gt;
&lt;retry-interval&gt;500&lt;/retry-interval&gt;
&lt;use-duplicate-detection&gt;true&lt;/use-duplicate-detection&gt;
&lt;message-load-balancing&gt;STRICT&lt;/message-load-balancing&gt;
&lt;max-hops&gt;1&lt;/max-hops&gt;
&lt;discovery-group-ref discovery-group-name="my-discovery-group"/&gt;
&lt;/cluster-connection&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>

View File

@ -0,0 +1,25 @@
# JMS Clustered Durable Subscription Example
To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually.
This example demonstrates a clustered JMS durable subscription. Normally durable subscriptions exist on a single node and can only have one subscriber at any one time, however, with ActiveMQ Artemis it's possible to create durable subscription instances with the same name and client-id on different nodes of the cluster, and consume from them simultaneously. This allows the work of processing messages from a durable subscription to be spread across the cluster in a similar way to how JMS Queues can be load balanced across the cluster
In this example we first configure the two nodes to form a cluster, then we then create a durable subscriber with the same name and client-id on both nodes, and we create a producer on only one of the nodes.
We then send some messages via the producer, and we verify that the messages are round robin'd between the two subscription instances. Note that each durable subscription instance with the same name and client-id **does not** receive its own copy of the messages. This is because the instances on different nodes form a single "logical" durable subscription, in the same way multiple JMS Queue instances on different nodes form a single "local" JMS Queue
This example uses JNDI to lookup the JMS Queue and ConnectionFactory objects. If you prefer not to use JNDI, these could be instantiated directly.
Here's the relevant snippet from the broker configuration, which tells the broker to form a cluster between the two nodes and to load balance the messages between the nodes.
The cli create method will define a similar section by default if you use `--clustered` as a parameter
<cluster-connection name="my-cluster">
<retry-interval>500</retry-interval>
<use-duplicate-detection>true</use-duplicate-detection>
<message-load-balancing>STRICT</message-load-balancing>
<max-hops>1</max-hops>
<discovery-group-ref discovery-group-name="my-discovery-group"/>
</cluster-connection>
For more information on ActiveMQ Artemis load balancing, and clustering in general, please see the "Clusters" chapter of the user manual.

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -84,7 +82,7 @@ under the License.
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleTopic"> <address name="exampleTopic">
<multicast/> <multicast/>
</address> </address>

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -84,7 +82,7 @@ under the License.
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleTopic"> <address name="exampleTopic">
<multicast/> <multicast/>
</address> </address>

View File

@ -29,7 +29,7 @@ under the License.
<artifactId>clustered-grouping</artifactId> <artifactId>clustered-grouping</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>ActiveMQ Artemis JMS CLustered Grouping Example</name> <name>ActiveMQ Artemis JMS Clustered Grouping Example</name>
<properties> <properties>
<activemq.basedir>${project.basedir}/../../../..</activemq.basedir> <activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
@ -193,7 +193,23 @@ under the License.
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
</plugin>
</plugins> </plugins>
</build> </build>
<profiles>
</project> <profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>markdown-page-generator-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -1,79 +0,0 @@
<!--
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 Clustered Grouping Example</title>
<link rel="stylesheet" type="text/css" href="../../../common/common.css">
</head>
<body>
<h1>JMS Clustered Grouping 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 how to ensure strict ordering across a cluster using clustered message grouping</p>
<p>We create 3 nodes each with a grouping message handler, one with a Local handler and 2 with a Remote handler.</p>
<p>The local handler acts as an arbitrator for the 2 remote handlers, holding the information on routes and communicating
the routing info with the remote handlers on the other 2 nodes</p>
<p>We then send some messages to each node with the same group id set and ensure the same consumer receives all of them</p>
<p>Here's the relevant snippet from the server configuration that has the local handler</p>
<pre>
<code>
&lt;cluster-connections&gt;
&lt;cluster-connection name="my-cluster"&gt;
&lt;connector-ref>netty-connector&lt;/connector-ref>
&lt;retry-interval&gt;500&lt;/retry-interval&gt;
&lt;use-duplicate-detection&gt;true&lt;/use-duplicate-detection&gt;
&lt;message-load-balancing&gt;STRICT&lt;/message-load-balancing&gt;
&lt;max-hops&gt;1&lt;/max-hops&gt;
&lt;discovery-group-ref discovery-group-name="my-discovery-group"/&gt;
&lt;/cluster-connection&gt;
&lt;/cluster-connections&gt;
&lt;grouping-handler name="my-grouping-handler"&gt;
&lt;type&gt;LOCAL&lt;/type&gt;
&lt;address&gt;jms&lt;/address&gt;
&lt;timeout&gt;5000&lt;/timeout&gt;
&lt;/grouping-handler&gt;
</code>
</pre>
<p>Here's the relevant snippet from the server configuration that has the remote handlers</p>
<pre>
<code>
&lt;cluster-connections&gt;
&lt;cluster-connection name="my-cluster"&gt;
&lt;retry-interval&gt;500&lt;/retry-interval&gt;
&lt;use-duplicate-detection&gt;true&lt;/use-duplicate-detection&gt;
&lt;message-load-balancing&gt;STRICT&lt;/message-load-balancing&gt;
&lt;max-hops&gt;1&lt;/max-hops&gt;
&lt;discovery-group-ref discovery-group-name="my-discovery-group"/&gt;
&lt;/cluster-connection&gt;
&lt;/cluster-connections&gt;
&lt;grouping-handler name="my-grouping-handler"&gt;
&lt;type&gt;REMOTE&lt;/type&gt;
&lt;address&gt;jms&lt;/address&gt;
&lt;timeout&gt;5000&lt;/timeout&gt;
&lt;/grouping-handler&gt;
</code>
</pre>
</body>
</html>

View File

@ -0,0 +1,48 @@
# JMS Clustered Grouping Example
To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually.
This example demonstrates how to ensure strict ordering across a cluster using clustered message grouping
We create 3 nodes each with a grouping message handler, one with a Local handler and 2 with a Remote handler.
The local handler acts as an arbitrator for the 2 remote handlers, holding the information on routes and communicating the routing info with the remote handlers on the other 2 nodes
We then send some messages to each node with the same group id set and ensure the same consumer receives all of them
Here's the relevant snippet from the broker configuration that has the local handler
<cluster-connections>
<cluster-connection name="my-cluster">
<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>
<discovery-group-ref discovery-group-name="my-discovery-group"/>
</cluster-connection>
</cluster-connections>
<grouping-handler name="my-grouping-handler">
<type>LOCAL</type>
<address>jms</address>
<timeout>5000</timeout>
</grouping-handler>
Here's the relevant snippet from the broker configuration that has the remote handlers
<cluster-connections>
<cluster-connection name="my-cluster">
<retry-interval>500</retry-interval>
<use-duplicate-detection>true</use-duplicate-detection>
<message-load-balancing>STRICT</message-load-balancing>
<max-hops>1</max-hops>
<discovery-group-ref discovery-group-name="my-discovery-group"/>
</cluster-connection>
</cluster-connections>
<grouping-handler name="my-grouping-handler">
<type>REMOTE</type>
<address>jms</address>
<timeout>5000</timeout>
</grouping-handler>

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -93,7 +91,7 @@ under the License.
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleQueue"> <address name="exampleQueue">
<anycast> <anycast>
<queue name="exampleQueue"/> <queue name="exampleQueue"/>

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -90,7 +88,7 @@ under the License.
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleQueue"> <address name="exampleQueue">
<anycast> <anycast>
<queue name="exampleQueue"/> <queue name="exampleQueue"/>

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -90,7 +88,7 @@ under the License.
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleQueue"> <address name="exampleQueue">
<anycast> <anycast>
<queue name="exampleQueue"/> <queue name="exampleQueue"/>

View File

@ -158,7 +158,23 @@ under the License.
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
</plugin>
</plugins> </plugins>
</build> </build>
<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>markdown-page-generator-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project> </project>

View File

@ -1,67 +0,0 @@
<!--
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 Clustering with JGroups 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>ActiveMQ Artemis Clustering with JGroups 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 the working of a two node cluster using JGroups as the underlying topology broadcasting/discovery
technique.</p>
<p>We deploy a queue on to the cluster, 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>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>To enable ActiveMQ Artemis to use JGroups you need to configure JGroups configuration file and make sure it is on the classpath
by placing in the configuration directory, the file test-jgroups-file_ping.xml is the configuration used in this
exaample</p>
<p>You then configure the jgroups file used by the broadcast and discovery groups in the configuration along with the
channel name which you want this cluster to share.</p>
<pre class="prettyprint">
<code>
&lt;broadcast-groups&gt;
&lt;broadcast-group name="my-broadcast-group">
&lt;broadcast-period>5000&lt;/broadcast-period>
&lt;jgroups-file>test-jgroups-file_ping.xml&lt;/jgroups-file>
&lt;jgroups-channel>activemq_broadcast_channel&lt;/jgroups-channel>
&lt;connector-ref>netty-connector&lt;/connector-ref>
&lt;/broadcast-group>
&lt;/broadcast-groups&gt;
&lt;discovery-groups&gt;
&lt;discovery-group name="my-discovery-group">
&lt;jgroups-file>test-jgroups-file_ping.xml&lt;/jgroups-file>
&lt;jgroups-channel>activemq_broadcast_channel&lt;/jgroups-channel>
&lt;refresh-timeout>10000&lt;/refresh-timeout>
&lt;/discovery-group>
&lt;/discovery-groups&gt;
</code>
</pre>
<p>For more information on ActiveMQ Artemis clustering in general, please see the clustering
section of the user manual.</p>
</body>
</html>

View File

@ -0,0 +1,34 @@
# ActiveMQ Artemis Clustering with JGroups Example
To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually.
This example demonstrates the working of a two node cluster using JGroups as the underlying topology broadcasting/discovery technique.
We deploy a queue on to the cluster, then create a consumer on the queue on each node, and we create a producer on only one of the nodes.
We then send some messages via the producer, and we verify that **both** consumers receive the sent messages in a round-robin fashion.
This example uses JNDI to lookup the JMS Queue and ConnectionFactory objects. If you prefer not to use JNDI, these could be instantiated directly.
To enable ActiveMQ Artemis to use JGroups you need to configure JGroups configuration file and make sure it is on the classpath by placing in the configuration directory, the file test-jgroups-file_ping.xml is the configuration used in this exaample
You then configure the jgroups file used by the broadcast and discovery groups in the configuration along with the channel name which you want this cluster to share.
<broadcast-groups>
<broadcast-group name="my-broadcast-group">
<broadcast-period>5000</broadcast-period>
<jgroups-file>test-jgroups-file_ping.xml</jgroups-file>
<jgroups-channel>activemq_broadcast_channel</jgroups-channel>
<connector-ref>netty-connector</connector-ref>
</broadcast-group>
</broadcast-groups>
<discovery-groups>
<discovery-group name="my-discovery-group">
<jgroups-file>test-jgroups-file_ping.xml</jgroups-file>
<jgroups-channel>activemq_broadcast_channel</jgroups-channel>
<refresh-timeout>10000</refresh-timeout>
</discovery-group>
</discovery-groups>
For more information on ActiveMQ Artemis clustering in general, please see the "Clusters" chapter of the user manual.

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -85,7 +83,7 @@ under the License.
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleQueue"> <address name="exampleQueue">
<anycast> <anycast>
<queue name="exampleQueue"/> <queue name="exampleQueue"/>

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -84,7 +82,7 @@ under the License.
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleQueue"> <address name="exampleQueue">
<anycast> <anycast>
<queue name="exampleQueue"/> <queue name="exampleQueue"/>

View File

@ -151,7 +151,23 @@ under the License.
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
</plugin>
</plugins> </plugins>
</build> </build>
<profiles>
</project> <profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>markdown-page-generator-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -1,55 +0,0 @@
<!--
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 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 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.</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>&lt;cluster-connection name="my-cluster"&gt;
&lt;connector-ref>netty-connector&lt;/connector-ref>
&lt;retry-interval&gt;500&lt;/retry-interval&gt;
&lt;use-duplicate-detection&gt;true&lt;/use-duplicate-detection&gt;
&lt;message-load-balancing&gt;STRICT&lt;/message-load-balancing&gt;
&lt;max-hops&gt;1&lt;/max-hops&gt;
&lt;discovery-group-ref discovery-group-name="my-discovery-group"/&gt;
&lt;/cluster-connection&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>

View File

@ -0,0 +1,26 @@
# JMS Load Balanced Clustered Queue Example
To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually.
This example demonstrates a JMS queue deployed on two different nodes. The two nodes are configured to form a cluster.
We then create a consumer on the queue on each node, and we create a producer on only one of the nodes.
We then send some messages via the producer, and we verify that **both** consumers receive the sent messages in a round-robin fashion.
In other words, ActiveMQ Artemis **load balances** the sent messages across all consumers on the cluster
This example uses JNDI to lookup the JMS Queue and ConnectionFactory objects. If you prefer not to use JNDI, these could be instantiated directly.
Here's the relevant snippet from the broker configuration, which tells the broker to form a cluster between the two nodes and to load balance the messages between the nodes.
<cluster-connection name="my-cluster">
<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>
<discovery-group-ref discovery-group-name="my-discovery-group"/>
</cluster-connection>
For more information on ActiveMQ Artemis load balancing, and clustering in general, please see the clustering section of the user manual.

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -83,7 +81,7 @@ under the License.
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleQueue"> <address name="exampleQueue">
<anycast> <anycast>
<queue name="exampleQueue"/> <queue name="exampleQueue"/>

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
@ -84,7 +82,7 @@ under the License.
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleQueue"> <address name="exampleQueue">
<anycast> <anycast>
<queue name="exampleQueue"/> <queue name="exampleQueue"/>

View File

@ -238,7 +238,23 @@ under the License.
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
</plugin>
</plugins> </plugins>
</build> </build>
<profiles>
</project> <profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>markdown-page-generator-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -1,57 +0,0 @@
<!--
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>&lt;cluster-connection name="my-cluster"&gt;
&lt;connector-ref>netty-connector&lt;/connector-ref>
&lt;retry-interval&gt;500&lt;/retry-interval&gt;
&lt;use-duplicate-detection&gt;true&lt;/use-duplicate-detection&gt;
&lt;message-load-balancing&gt;STRICT&lt;/message-load-balancing&gt;
&lt;max-hops&gt;1&lt;/max-hops&gt;
&lt;static-connectors>
&lt;connector-ref>server1-connector&lt;/connector-ref>
&lt;/static-connectors>
&lt;/cluster-connection&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>

View File

@ -0,0 +1,28 @@
# JMS Load Balanced Static Clustered Queue Example
To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually.
This example demonstrates a JMS queue deployed on two different nodes. The two nodes are configured to form a cluster from a _static_ list of nodes.
We then create a consumer on the queue on each node, and we create a producer on only one of the nodes.
We then send some messages via the producer, and we verify that **both** consumers receive the sent messages in a round-robin fashion.
In other words, ActiveMQ Artemis **load balances** the sent messages across all consumers on the cluster
This example uses JNDI to lookup the JMS Queue and ConnectionFactory objects. If you prefer not to use JNDI, these could be instantiated directly.
Here's the relevant snippet from the broker configuration, which tells the broker to form a cluster between the two nodes and to load balance the messages between the nodes.
<cluster-connection name="my-cluster">
<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>
For more information on ActiveMQ Artemis load balancing, and clustering in general, please see the clustering section of the user manual.

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -59,7 +57,7 @@ under the License.
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleQueue"> <address name="exampleQueue">
<anycast> <anycast>
<queue name="exampleQueue"/> <queue name="exampleQueue"/>

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -59,7 +57,7 @@ under the License.
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleQueue"> <address name="exampleQueue">
<anycast> <anycast>
<queue name="exampleQueue"/> <queue name="exampleQueue"/>

View File

@ -14,10 +14,8 @@
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and ~ See the License for the specific language governing permissions and
~ limitations under the License. ~ limitations under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -56,7 +54,7 @@
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleQueue"> <address name="exampleQueue">
<anycast> <anycast>
<queue name="exampleQueue"/> <queue name="exampleQueue"/>

View File

@ -14,10 +14,8 @@
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and ~ See the License for the specific language governing permissions and
~ limitations under the License. ~ limitations under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -57,7 +55,7 @@
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleQueue"> <address name="exampleQueue">
<anycast> <anycast>
<queue name="exampleQueue"/> <queue name="exampleQueue"/>

View File

@ -238,7 +238,23 @@ under the License.
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
</plugin>
</plugins> </plugins>
</build> </build>
<profiles>
</project> <profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>markdown-page-generator-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -1,57 +0,0 @@
<!--
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>&lt;cluster-connection name="my-cluster"&gt;
&lt;connector-ref>netty-connector&lt;/connector-ref>
&lt;retry-interval&gt;500&lt;/retry-interval&gt;
&lt;use-duplicate-detection&gt;true&lt;/use-duplicate-detection&gt;
&lt;message-load-balancing&gt;STRICT&lt;/message-load-balancing&gt;
&lt;max-hops&gt;1&lt;/max-hops&gt;
&lt;static-connectors>
&lt;connector-ref>server1-connector&lt;/connector-ref>
&lt;/static-connectors>
&lt;/cluster-connection&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>

View File

@ -0,0 +1,28 @@
# JMS Load Balanced Static Clustered Queue Example
To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually.
This example demonstrates a JMS queue deployed on two different nodes. The two nodes are configured to form a cluster from a _static_ list of nodes.
We then create a consumer on the queue on each node, and we create a producer on only one of the nodes.
We then send some messages via the producer, and we verify that **both** consumers receive the sent messages in a round-robin fashion.
In other words, ActiveMQ Artemis **load balances** the sent messages across all consumers on the cluster
This example uses JNDI to lookup the JMS Queue and ConnectionFactory objects. If you prefer not to use JNDI, these could be instantiated directly.
Here's the relevant snippet from the broker configuration, which tells the broker to form a cluster between the two nodes and to load balance the messages between the nodes.
<cluster-connection name="my-cluster">
<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>
For more information on ActiveMQ Artemis load balancing, and clustering in general, please see the clustering section of the user manual.

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -70,7 +68,7 @@ under the License.
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleQueue"> <address name="exampleQueue">
<anycast> <anycast>
<queue name="exampleQueue"/> <queue name="exampleQueue"/>

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -70,7 +68,7 @@ under the License.
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleQueue"> <address name="exampleQueue">
<anycast> <anycast>
<queue name="exampleQueue"/> <queue name="exampleQueue"/>

View File

@ -14,10 +14,8 @@
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and ~ See the License for the specific language governing permissions and
~ limitations under the License. ~ limitations under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -68,7 +66,7 @@
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleQueue"> <address name="exampleQueue">
<anycast> <anycast>
<queue name="exampleQueue"/> <queue name="exampleQueue"/>

View File

@ -14,10 +14,8 @@
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and ~ See the License for the specific language governing permissions and
~ limitations under the License. ~ limitations under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -68,7 +66,7 @@
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleQueue"> <address name="exampleQueue">
<anycast> <anycast>
<queue name="exampleQueue"/> <queue name="exampleQueue"/>

View File

@ -198,6 +198,23 @@ under the License.
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
</plugin>
</plugins> </plugins>
</build> </build>
</project> <profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>markdown-page-generator-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -1,63 +0,0 @@
<!--
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 One Way 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 three different nodes. The three nodes are configured to form a one way cluster
from a <em>static</em> list of nodes. </p>
<p>A one way cluster is different from a symmetrical cluster in that each node is only connected to one another node in
a chain type fashion, so server 0 -> server 1 -> server 2</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>all</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 one way cluster between the three nodes
and to load balance the messages between the nodes. Note that we have set <em>allow-direct-connections-only</em> to true,
this means that this server will only ever connect the address's specified in the list of connectors. ALso notice
that <em>max-hops</em> is 2, this is because server 0 is not directly connected to server 2, 2 hops in fact, so we
allow any updates from servers up to 2 hops away</p>
<pre class="prettyprint">
<code>
&lt;cluster-connection name="my-cluster"&gt;
&lt;connector-ref>netty-connector&lt;/connector-ref>
&lt;retry-interval&gt;500&lt;/retry-interval&gt;
&lt;use-duplicate-detection&gt;true&lt;/use-duplicate-detection&gt;
&lt;message-load-balancing&gt;STRICT&lt;/message-load-balancing&gt;
&lt;max-hops&gt;2&lt;/max-hops&gt;
&lt;static-connectors allow-direct-connections-only="true"&gt;
&lt;connector-ref>server1-connector&lt;/connector-ref&gt;
&lt;/static-connectors&gt;
&lt;/cluster-connection&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>

View File

@ -0,0 +1,30 @@
# JMS Load Balanced Static Clustered One Way Queue Example
To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually.
This example demonstrates a JMS queue deployed on three different nodes. The three nodes are configured to form a one way cluster from a _static_ list of nodes.
A one way cluster is different from a symmetrical cluster in that each node is only connected to one another node in a chain type fashion, so broker 0 -> broker 1 -> broker 2
We then create a consumer on the queue on each node, and we create a producer on only one of the nodes.
We then send some messages via the producer, and we verify that **all** consumers receive the sent messages in a round-robin fashion.
In other words, ActiveMQ Artemis **load balances** the sent messages across all consumers on the cluster
This example uses JNDI to lookup the JMS Queue and ConnectionFactory objects. If you prefer not to use JNDI, these could be instantiated directly.
Here's the relevant snippet from the broker configuration, which tells the broker to form a one way cluster between the three nodes and to load balance the messages between the nodes. Note that we have set _allow-direct-connections-only_ to true, this means that this broker will only ever connect the address's specified in the list of connectors. ALso notice that _max-hops_ is 2, this is because broker 0 is not directly connected to broker 2, 2 hops in fact, so we allow any updates from servers up to 2 hops away
<cluster-connection name="my-cluster">
<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>2</max-hops>
<static-connectors allow-direct-connections-only="true">
<connector-ref>server1-connector</connector-ref>
</static-connectors>
</cluster-connection>
For more information on ActiveMQ Artemis load balancing, and clustering in general, please see the clustering section of the user manual.

View File

@ -14,10 +14,8 @@
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and ~ See the License for the specific language governing permissions and
~ limitations under the License. ~ limitations under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<name>broker0</name> <name>broker0</name>
@ -70,7 +68,7 @@
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleQueue"> <address name="exampleQueue">
<anycast> <anycast>
<queue name="exampleQueue"/> <queue name="exampleQueue"/>

View File

@ -14,10 +14,8 @@
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and ~ See the License for the specific language governing permissions and
~ limitations under the License. ~ limitations under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<name>broker1</name> <name>broker1</name>
@ -70,7 +68,7 @@
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleQueue"> <address name="exampleQueue">
<anycast> <anycast>
<queue name="exampleQueue"/> <queue name="exampleQueue"/>

View File

@ -14,10 +14,8 @@
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and ~ See the License for the specific language governing permissions and
~ limitations under the License. ~ limitations under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<name>broker2</name> <name>broker2</name>
@ -65,7 +63,7 @@
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleQueue"> <address name="exampleQueue">
<anycast> <anycast>
<queue name="exampleQueue"/> <queue name="exampleQueue"/>

View File

@ -29,7 +29,7 @@ under the License.
<artifactId>clustered-topic-uri</artifactId> <artifactId>clustered-topic-uri</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>ActiveMQ Artemis JMS Clustered Topic Example</name> <name>ActiveMQ Artemis JMS Clustered Topic URI Example</name>
<properties> <properties>
<activemq.basedir>${project.basedir}/../../../..</activemq.basedir> <activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
@ -151,6 +151,23 @@ under the License.
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
</plugin>
</plugins> </plugins>
</build> </build>
</project> <profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>markdown-page-generator-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -1,46 +0,0 @@
<!--
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 Clustered Topic 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 Topic 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 Topic deployed on two different nodes. The two nodes are configured to form a cluster.</p>
<p>We then create a subscriber on the topic 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> subscribers receive all the
sent messages.</p>
<p>A JMS Topic is an example of <b>publish-subscribe</b> messaging where all subscribers receive all the
messages sent to the topic (assuming they have no message selectors).</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>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>
<p>This example differes from different-topic as it will use an URI to define the cluster connection.</p>
<pre class="prettyprint"><code>&lt;cluster-connection-uri name="my-cluster" address="uri="multicast://my-discovery-group?messageLoadBalancingType=STRICT;retryInterval=500;connectorName=netty-connector;maxHops=1"/&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>

View File

@ -0,0 +1,21 @@
# JMS Clustered Topic URI Example
To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually.
This example demonstrates a JMS Topic deployed on two different nodes. The two nodes are configured to form a cluster.
We then create a subscriber on the topic on each node, and we create a producer on only one of the nodes.
We then send some messages via the producer, and we verify that **both** subscribers receive all the sent messages.
A JMS Topic is an example of **publish-subscribe** messaging where all subscribers receive all the messages sent to the topic (assuming they have no message selectors).
This example uses JNDI to lookup the JMS Queue and ConnectionFactory objects. If you prefer not to use JNDI, these could be instantiated directly.
Here's the relevant snippet from the broker configuration, which tells the broker to form a cluster between the two nodes and to load balance the messages between the nodes.
This example differs from different-topic as it will use an URI to define the cluster connection.
<cluster-connection-uri name="my-cluster" address="uri="multicast://my-discovery-group?messageLoadBalancingType=STRICT;retryInterval=500;connectorName=netty-connector;maxHops=1"/>
For more information on ActiveMQ Artemis load balancing, and clustering in general, please see the clustering section of the user manual.

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -78,7 +76,7 @@ under the License.
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleTopic"> <address name="exampleTopic">
<multicast/> <multicast/>
</address> </address>

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -76,7 +74,7 @@ under the License.
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleTopic"> <address name="exampleTopic">
<multicast/> <multicast/>
</address> </address>

View File

@ -151,6 +151,23 @@ under the License.
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
</plugin>
</plugins> </plugins>
</build> </build>
</project> <profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>markdown-page-generator-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -1,54 +0,0 @@
<!--
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 Clustered Topic 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 Topic 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 Topic deployed on two different nodes. The two nodes are configured to form a cluster.</p>
<p>We then create a subscriber on the topic 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> subscribers receive all the
sent messages.</p>
<p>A JMS Topic is an example of <b>publish-subscribe</b> messaging where all subscribers receive all the
messages sent to the topic (assuming they have no message selectors).</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>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>&lt;cluster-connection name="my-cluster"&gt;
&lt;retry-interval&gt;500&lt;/retry-interval&gt;
&lt;use-duplicate-detection&gt;true&lt;/use-duplicate-detection&gt;
&lt;message-load-balancing&gt;STRICT&lt;/message-load-balancing&gt;
&lt;max-hops&gt;1&lt;/max-hops&gt;
&lt;discovery-group-ref discovery-group-name="my-discovery-group"/&gt;
&lt;/cluster-connection&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>

View File

@ -0,0 +1,25 @@
# JMS Clustered Topic Example
To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually.
This example demonstrates a JMS Topic deployed on two different nodes. The two nodes are configured to form a cluster.
We then create a subscriber on the topic on each node, and we create a producer on only one of the nodes.
We then send some messages via the producer, and we verify that **both** subscribers receive all the sent messages.
A JMS Topic is an example of **publish-subscribe** messaging where all subscribers receive all the messages sent to the topic (assuming they have no message selectors).
This example uses JNDI to lookup the JMS Queue and ConnectionFactory objects. If you prefer not to use JNDI, these could be instantiated directly.
Here's the relevant snippet from the broker configuration, which tells the broker to form a cluster between the two nodes and to load balance the messages between the nodes.
<cluster-connection name="my-cluster">
<retry-interval>500</retry-interval>
<use-duplicate-detection>true</use-duplicate-detection>
<message-load-balancing>STRICT</message-load-balancing>
<max-hops>1</max-hops>
<discovery-group-ref discovery-group-name="my-discovery-group"/>
</cluster-connection>
For more information on ActiveMQ Artemis load balancing, and clustering in general, please see the clustering section of the user manual.

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -85,7 +83,7 @@ under the License.
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleTopic"> <address name="exampleTopic">
<multicast/> <multicast/>
</address> </address>

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -83,7 +81,7 @@ under the License.
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleTopic"> <address name="exampleTopic">
<multicast/> <multicast/>
</address> </address>

View File

@ -152,7 +152,23 @@ under the License.
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
</plugin>
</plugins> </plugins>
</build> </build>
<profiles>
</project> <profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>markdown-page-generator-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -1,61 +0,0 @@
<!--
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>

View File

@ -0,0 +1,23 @@
# Message Redistribution Example
To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually.
This example demonstrates message redistribution between queues with the same name deployed in different nodes of a cluster.
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 broker side.
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.
If this is undesirable, ActiveMQ Artemis can be configured to **redistribute** 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.
By default, message redistribution is disabled, but can be enabled by specifying some AddressSettings configuration in either `activemq-queues.xml` or `broker.xml`
Setting `redistribution-delay` to `0` 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.
Here's the relevant snippet from the `activemq-queues.xml` configuration, which tells the broker to use a redistribution delay of `0` on any jms queues, i.e. any queues whose name starts with `jms.`
<address-setting match="#">
<redistribution-delay>0</redistribution-delay>
</address-setting>
For more information on ActiveMQ Artemis load balancing, and clustering in general, please see the clustering section of the user manual.

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -84,7 +82,7 @@ under the License.
</security-settings> </security-settings>
<address-settings> <address-settings>
<!-- We set a redistribution delay of zero on all jms queues and topic subscriptions <!-- We set a redistribution delay of zero on everything.
Default redistribution delay as -1 which means "disable redistribution" Default redistribution delay as -1 which means "disable redistribution"
Setting it to a value > 0 means how long to wait before redistributing, if a consumer is closed Setting it to a value > 0 means how long to wait before redistributing, if a consumer is closed
then another one quickly recreated you might want to set it thus, to avoid unnecessary then another one quickly recreated you might want to set it thus, to avoid unnecessary
@ -94,10 +92,10 @@ under the License.
</address-setting> </address-setting>
</address-settings> </address-settings>
<addresses> <addresses>
<address name="exampleQueue"> <address name="exampleQueue">
<anycast> <anycast>
<queue name="jms.queue.exampleQueue"/> <queue name="exampleQueue"/>
</anycast> </anycast>
</address> </address>
</addresses> </addresses>

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -85,7 +83,7 @@ under the License.
</security-settings> </security-settings>
<address-settings> <address-settings>
<!-- We set a redistribution delay of zero on all jms queues and topic subscriptions <!-- We set a redistribution delay of zero on everything.
Default redistribution delay as -1 which means "disable redistribution" Default redistribution delay as -1 which means "disable redistribution"
Setting it to a value > 0 means how long to wait before redistributing, if a consumer is closed Setting it to a value > 0 means how long to wait before redistributing, if a consumer is closed
then another one quickly recreated you might want to set it thus, to avoid unnecessary then another one quickly recreated you might want to set it thus, to avoid unnecessary
@ -95,10 +93,10 @@ under the License.
</address-setting> </address-setting>
</address-settings> </address-settings>
<addresses> <addresses>
<address name="exampleQueue"> <address name="exampleQueue">
<anycast> <anycast>
<queue name="jms.queue.exampleQueue"/> <queue name="exampleQueue"/>
</anycast> </anycast>
</address> </address>
</addresses> </addresses>

View File

@ -313,7 +313,23 @@ under the License.
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
</plugin>
</plugins> </plugins>
</build> </build>
<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>markdown-page-generator-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project> </project>

View File

@ -1,73 +0,0 @@
<!--
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 Symmetric Cluster 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 Symmetric Cluster 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 examples demonstrates a <b>symmetric cluster</b> set-up with ActiveMQ Artemis.</p>
<p>ActiveMQ Artemis has extremely flexible clustering which allows you to set-up servers in
many different topologies.</p>
<p>The most common topology that you'll perhaps be familiar with if you are used to application
server clustering is a <b>symmetric cluster</b>.</p>
<p>With a symmetric cluster, the cluster is homogeneous, i.e. each node is configured the same
as every other node, and every node is connected to every other node in the cluster.</p>
<p>By connecting node in such a way, we can, from a JMS point of view, give the impression of distributed
JMS queues and topics.</p>
<p>The configuration used in this example is very similar to the configuration used by ActiveMQ
when installed as a clustered profile in JBoss Application Server.</p>
<p>To set up ActiveMQ Artemis to form a symmetric cluster we simply need to mark each server as <code>clustered</code>
and we need to define a <code>cluster-connection</code> in <code>broker.xml</code>.</p>
<p>The <code>cluster-connection</code> tells the nodes what other nodes to make connections to.
With a <code>cluster-connection</code> each node that we connect to can either be specified
indivually, or we can use UDP discovery to find out what other nodes are in the cluster.</p>
<p>Using UDP discovery makes configuration simpler since we don't have to know what nodes are
available at any one time.</p>
<p>Here's the relevant snippet from the server configuration, which tells the server to form a cluster
with the other nodes:</p>
<pre class="prettyprint">
<code>
&lt;cluster-connection name="my-cluster"&gt;
&lt;connector-ref>netty-connector&lt;/connector-ref>
&lt;retry-interval&gt;500&lt;/retry-interval&gt;
&lt;use-duplicate-detection&gt;true&lt;/use-duplicate-detection&gt;
&lt;message-load-balancing&gt;STRICT&lt;/message-load-balancing&gt;
&lt;max-hops&gt;1&lt;/max-hops&gt;
&lt;discovery-group-ref discovery-group-name="my-discovery-group"/&gt;
&lt;/cluster-connection&gt;
</code>
</pre>
<p>In this example we create a symmetric cluster of six live nodes, and we also pair each live node
with it's own backup node. (A backup node is not strictly necessary for a symmetric cluster).</p>
<p>In this example will we will demonstrate this by deploying a JMS topic and Queue on all nodes of the cluster
, sending messages to the queue and topic from different nodes, and verifying messages are received correctly
by consumers on different nodes.</p>
<p>For more information on configuring ActiveMQ Artemis clustering in general, please see the clustering
section of the user manual.</p>
</body>
</html>

View File

@ -0,0 +1,38 @@
# JMS Symmetric Cluster Example
To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually.
This examples demonstrates a **symmetric cluster** set-up with ActiveMQ Artemis.
ActiveMQ Artemis has extremely flexible clustering which allows you to set-up servers in many different topologies.
The most common topology that you'll perhaps be familiar with if you are used to application broker clustering is a **symmetric cluster**.
With a symmetric cluster, the cluster is homogeneous, i.e. each node is configured the same as every other node, and every node is connected to every other node in the cluster.
By connecting node in such a way, we can, from a JMS point of view, give the impression of distributed JMS queues and topics.
The configuration used in this example is very similar to the configuration used by ActiveMQ when installed as a clustered profile in JBoss Application Server.
To set up ActiveMQ Artemis to form a symmetric cluster we simply need to mark each broker as `clustered` and we need to define a `cluster-connection` in `broker.xml`.
The `cluster-connection` tells the nodes what other nodes to make connections to. With a `cluster-connection` each node that we connect to can either be specified indivually, or we can use UDP discovery to find out what other nodes are in the cluster.
Using UDP discovery makes configuration simpler since we don't have to know what nodes are available at any one time.
Here's the relevant snippet from the broker configuration, which tells the broker to form a cluster with the other nodes:
<cluster-connection name="my-cluster">
<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>
<discovery-group-ref discovery-group-name="my-discovery-group"/>
</cluster-connection>
In this example we create a symmetric cluster of six live nodes, and we also pair each live node with it's own backup node. (A backup node is not strictly necessary for a symmetric cluster).
In this example will we will demonstrate this by deploying a JMS topic and Queue on all nodes of the cluster , sending messages to the queue and topic from different nodes, and verifying messages are received correctly by consumers on different nodes.
For more information on configuring ActiveMQ Artemis clustering in general, please see the clustering section of the user manual.

View File

@ -45,7 +45,7 @@ import org.apache.activemq.artemis.api.jms.JMSFactoryType;
* servers at different times, and verify that they transparently fail over onto their backup * servers at different times, and verify that they transparently fail over onto their backup
* servers. * servers.
* <p> * <p>
* Please see the readme.html file for more information. * Please see the readme for more information.
*/ */
public class SymmetricClusterExample { public class SymmetricClusterExample {

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -86,7 +84,7 @@ under the License.
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleTopic"> <address name="exampleTopic">
<multicast/> <multicast/>
</address> </address>

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -84,7 +82,7 @@ under the License.
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleTopic"> <address name="exampleTopic">
<multicast/> <multicast/>
</address> </address>

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -84,7 +82,7 @@ under the License.
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleTopic"> <address name="exampleTopic">
<multicast/> <multicast/>
</address> </address>

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -84,7 +82,7 @@ under the License.
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleTopic"> <address name="exampleTopic">
<multicast/> <multicast/>
</address> </address>

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -83,7 +81,7 @@ under the License.
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleTopic"> <address name="exampleTopic">
<multicast/> <multicast/>
</address> </address>

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -83,7 +81,7 @@ under the License.
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleTopic"> <address name="exampleTopic">
<multicast/> <multicast/>
</address> </address>

View File

@ -99,7 +99,23 @@ under the License.
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
</plugin>
</plugins> </plugins>
</build> </build>
<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>markdown-page-generator-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project> </project>

View File

@ -1,169 +0,0 @@
<!--
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 Application-Layer Failover 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>Application-Layer Failover Example</h1>
<pre>To run the example, simply type <b>mvn verify</b> from this directory. This example will always spawn and stop multiple servers.</pre>
<p>ActiveMQ Artemis implements fully transparent <b>automatic</b> failover of connections from a live node to a backup node which requires
no special coding. This is described in a different example and requires server replication.</p>
<p>However, ActiveMQ Artemis also supports <b>Application-Layer</b> failover which is useful in the case where replication is not enabled.</p>
<p>With Application-Layer failover, it's up to the application to register a JMS ExceptionListener with ActiveMQ Artemis.
This listener will then be called by ActiveMQ Artemis in the event that connection failure is detected.</p>
<p>User code in the ExceptionListener can then recreate any JMS Connection, Session, etc on another node and the application
can continue.</p>
<p>Application-Layer failover is an alternative approach to High Availability (HA).</p>
<p>Application-Layer failover differs from automatic failover in that some client side coding is required in order
to implement this. Also, with Application-Layer failover, since the old Session object dies and a new is created, any uncommitted
work in the old Session will be lost, and any unacknowledged messages might be redelivered.</p>
<p>For more information on ActiveMQ Artemis failover and HA, and clustering in general, please see the clustering
section of the user manual.</p>
<h2>Example step-by-step</h2>
<p>In this example, the live server is server 1, which will failover onto server 0.</p>
<p>The connection will initially be created to server1, server 1 will crash, and the client will carry on
on server 0, the new server. With Application-Layer failover the node that is failed over onto, does not need to
be specially configured as a backup server, it can be any node.</p>
<ol>
<li> We create our JMS Connection, Session, MessageProducer and MessageConsumer on server 1</li>
<pre class="prettyprint">
<code>createJMSObjects(1);</code>
</pre>
<li>We set a JMS ExceptionListener on the connection. On failure this will be called and the connection,
session, etc. will be manually recreated on the backup node.</li>
<pre class="prettyprint">
<code>connection.setExceptionListener(new ExampleListener());</code>
</pre>
<li>We send some messages to server 1, the live server.</li>
<pre class="prettyprint">
<code>
final int numMessages = 10;
for (int i = 0; i < numMessages; i++)
{
TextMessage message = session.createTextMessage("This is text message " + i);
producer.send(message);
System.out.println("Sent message: " + message.getText());
}
</code>
</pre>
<li>We consume those messages on server 1.</li>
<pre class="prettyprint">
<code>
for (int i = 0; i < numMessages; i++)
{
TextMessage message0 = (TextMessage)consumer.receive(5000);
System.out.println("Got message: " + message0.getText());
}
</code>
</pre>
<li>We now cause server 1, the live server to crash. After a little while the connection's
ExceptionListener will register the failure and reconnection will occur.</li>
<pre class="prettyprint">
<code>killServer(1);</code>
</pre>
<li>The connection's ExceptionListener gets called, and we lookup the JMS objects and
recreate the connection, session, etc on the other node 0.</li>
<pre class="prettyprint">
<code>
private class ExampleListener implements ExceptionListener
{
public void onException(JMSException exception)
{
try
{
// Close the old resources
closeResources();
// Create new JMS objects on the backup server
createJMSObjects(0);
failoverLatch.countDown();
}
catch (Exception e)
{
System.err.println("Failed to handle failover");
e.printStackTrace();
}
}
}
</code>
</pre>
<li>We are now connected to the other node. We now send some more messages.</li>
<pre class="prettyprint">
<code>
for (int i = numMessages; i < numMessages * 2; i++)
{
TextMessage message = session.createTextMessage("This is text message " + i);
producer.send(message);
System.out.println("Sent message: " + message.getText());
}
</code>
</pre>
<li>And consume them.</li>
<pre class="prettyprint">
<code>
for (int i = 0; i < numMessages; i++)
{
TextMessage message0 = (TextMessage)consumer.receive(5000);
System.out.println("Got message: " + message0.getText());
}
</code>
</pre>
<li>And finally (no pun intended), <b>always</b> remember to close your resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
<pre class="prettyprint">
<code>
finally
{
closeResources();
}
</code>
</pre>
</ol>
</body>
</html>

View File

@ -0,0 +1,17 @@
# JMS Application-Layer Failover Example
To run the example, simply type **mvn verify** from this directory. This example will always spawn and stop multiple brokers.
ActiveMQ Artemis implements fully transparent **automatic** failover of connections from a live node to a backup node which requires no special coding. This is described in a different example and requires broker replication.
However, ActiveMQ Artemis also supports **Application-Layer** failover which is useful in the case where replication is not enabled.
With Application-Layer failover, it's up to the application to register a JMS ExceptionListener with ActiveMQ Artemis. This listener will then be called by ActiveMQ Artemis in the event that connection failure is detected.
User code in the ExceptionListener can then recreate any JMS Connection, Session, etc on another node and the application can continue.
Application-Layer failover is an alternative approach to High Availability (HA).
Application-Layer failover differs from automatic failover in that some client side coding is required in order to implement this. Also, with Application-Layer failover, since the old Session object dies and a new is created, any uncommitted work in the old Session will be lost, and any unacknowledged messages might be redelivered.
For more information on ActiveMQ Artemis failover and HA, and clustering in general, please see the clustering section of the user manual.

View File

@ -27,9 +27,9 @@ under the License.
<version>2.5.0-SNAPSHOT</version> <version>2.5.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>client-side-fileoverlistener</artifactId> <artifactId>client-side-failoverlistener</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>ActiveMQ Artemis JMS Client Side Failover listener Example</name> <name>ActiveMQ Artemis JMS Client Side Failover Listener Example</name>
<properties> <properties>
<activemq.basedir>${project.basedir}/../../../..</activemq.basedir> <activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
@ -106,7 +106,23 @@ under the License.
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
</plugin>
</plugins> </plugins>
</build> </build>
<profiles>
</project> <profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>markdown-page-generator-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -1,37 +0,0 @@
<!--
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 Client Side Failover Listener 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>Client Side Kickoff Example</h1>
<pre>To run the example, simply type <b>mvn verify</b> from this directory. This example will always spawn and stop multiple servers.</pre>
<p>This example demonstrates how you can listen on failover event on the client side.</p>
<p>In this example there are two nodes running in a cluster, both server will be running for start,
but after a while the first server will crash. This will trigger a fail-over event.</p>
</body>
</html>

View File

@ -0,0 +1,7 @@
# JMS Client Side Failover Listener Example
To run the example, simply type **mvn verify** from this directory. This example will always spawn and stop multiple servers.
This example demonstrates how you can listen on failover event on the client side.
In this example there are two nodes running in a cluster, both broker will be running for start, but after a while the first broker will crash. This will trigger a fail-over event.

View File

@ -100,7 +100,23 @@ under the License.
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
</plugin>
</plugins> </plugins>
</build> </build>
<profiles>
</project> <profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>markdown-page-generator-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -1,65 +0,0 @@
<!--
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 Colocated Failover Scale Down 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 Colocated Failover Recover Only Example</h1>
<pre>To run the example, simply type <b>mvn verify</b> from this directory. This example will always spawn and stop multiple servers.</pre>
<p>This example demonstrates how you can colocate live and backup servers in the same VM. We do this by creating an
HA Policy that is colocated. colocated means that backup servers can be created and maintained by live servers on behalf
of other requesting live servers. In this example we create a colocated shared store server that will scale down.
That is it will not become live but scale down the journal to the colocated live server.
<p>This example starts 2 live servers each will request the other to create a backup.</p>
<p>The first live server will be killed and the backup in the second will recover the journal and recreate its state
in the live server it shares its VM with.</p>
<p>The following shows how to configure the backup, the slave is configured <b>&lt;scale-down/></b> which means
that the backup server will not fully start on fail over, instead it will just recover the journal and write it
to its parent live server.</p>
<pre class="prettyprint">
<code>&lt;ha-policy>
&lt;shared-store>
&lt;colocated>
&lt;backup-port-offset>100&lt;/backup-port-offset>
&lt;backup-request-retries>-1&lt;/backup-request-retries>
&lt;backup-request-retry-interval>2000&lt;/backup-request-retry-interval>
&lt;max-backups>1&lt;/max-backups>
&lt;request-backup>true&lt;/request-backup>
&lt;master/>
&lt;slave>
&lt;scale-down/>
&lt;/slave>
&lt;/colocated>
&lt;/shared-store>
&lt;/ha-policy>
</code>
</pre>
<p>Notice that we dont need to specify a scale down connector as it will use most appropriate
from the list of available connectors which in this case is the first INVM connector</p>
<p> One other thing to notice is that the cluster connection has its reconnect attempts set to 5, this is so it will
disconnect instead of trying to reconnect to a backup that doesn't exist.</p>
</body>
</html>

View File

@ -0,0 +1,31 @@
# JMS Colocated Failover Recover Only Example
To run the example, simply type **mvn verify** from this directory. This example will always spawn and stop multiple servers.
This example demonstrates how you can colocate live and backup servers in the same VM. We do this by creating an HA Policy that is colocated. Colocated means that backup servers can be created and maintained by live servers on behalf of other requesting live servers. In this example we create a colocated shared store broker that will scale down. That is it will not become live but scale down the journal to the colocated live server.
This example starts 2 live servers each will request the other to create a backup.
The first live broker will be killed and the backup in the second will recover the journal and recreate its state in the live broker it shares its VM with.
The following shows how to configure the backup, the slave is configured **<scale-down/>** which means that the backup broker will not fully start on fail over, instead it will just recover the journal and write it to its parent live server.
<ha-policy>
<shared-store>
<colocated>
<backup-port-offset>100</backup-port-offset>
<backup-request-retries>-1</backup-request-retries>
<backup-request-retry-interval>2000</backup-request-retry-interval>
<max-backups>1</max-backups>
<request-backup>true</request-backup>
<master/>
<slave>
<scale-down/>
</slave>
</colocated>
</shared-store>
</ha-policy>
Notice that we dont need to specify a scale down connector as it will use most appropriate from the list of available connectors which in this case is the first INVM connector
One other thing to notice is that the cluster connection has its reconnect attempts set to 5, this is so it will disconnect instead of trying to reconnect to a backup that doesn't exist.

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -117,7 +115,7 @@ under the License.
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleQueue"> <address name="exampleQueue">
<anycast> <anycast>
<queue name="exampleQueue"/> <queue name="exampleQueue"/>

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -115,7 +113,7 @@ under the License.
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleQueue"> <address name="exampleQueue">
<anycast> <anycast>
<queue name="exampleQueue"/> <queue name="exampleQueue"/>

View File

@ -100,6 +100,23 @@ under the License.
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
</plugin>
</plugins> </plugins>
</build> </build>
</project> <profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>markdown-page-generator-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -1,56 +0,0 @@
<!--
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 Colocated Failover 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 Colocated Failover Shared Store Example</h1>
<pre>To run the example, simply type <b>mvn verify</b> from this directory. This example will always spawn and stop multiple servers.</pre>
<p>This example demonstrates how you can colocate live and backup servers in the same VM. We do this by creating an
HA Policy that is colocated. colocated means that backup servers can be created and maintained by live servers on behalf
of other requesting live servers. In this example we create a colocated shared store server.
<p>This example starts 2 live servers each with a backup server that backs up the other live server.</p>
<p>The first live server will be killed and the backup in the second will become live</p>
<p>The following shows how to configure the live servers to request and allow backups to be deployed</p>
<pre class="prettyprint">
<code>&lt;ha-policy>
&lt;shared-store>
&lt;colocated>
&lt;backup-port-offset>100&lt;/backup-port-offset>
&lt;backup-request-retries>-1&lt;/backup-request-retries>
&lt;backup-request-retry-interval>2000&lt;/backup-request-retry-interval>
&lt;max-backups>1&lt;/max-backups>
&lt;request-backup>true&lt;/request-backup>
&lt;master/>
&lt;slave/>
&lt;/colocated>
&lt;/shared-store>
&lt;/ha-policy>
</code>
</pre>
<p>notice that we have used a template to set some sensible defaults but overridden the backup strategy so back ups
are full servers</p>
</body>
</html>

View File

@ -0,0 +1,27 @@
# JMS Colocated Failover Shared Store Example
To run the example, simply type **mvn verify** from this directory. This example will always spawn and stop multiple brokers.
This example demonstrates how you can colocate live and backup brokers in the same VM. We do this by creating an HA Policy that is colocated. Colocated means that backup brokers can be created and maintained by live brokers on behalf of other live brokers requesting a backup. In this example we create a colocated shared store broker.
This example starts 2 live brokers each with a backup broker that backs up the other live broker.
The first live broker will be killed and the backup in the second will become live
The following shows how to configure the live brokers to request and allow backups to be deployed
<ha-policy>
<shared-store>
<colocated>
<backup-port-offset>100</backup-port-offset>
<backup-request-retries>-1</backup-request-retries>
<backup-request-retry-interval>2000</backup-request-retry-interval>
<max-backups>1</max-backups>
<request-backup>true</request-backup>
<master/>
<slave/>
</colocated>
</shared-store>
</ha-policy>
notice that we have used a template to set some sensible defaults but overridden the backup strategy so back ups are full brokers.

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -103,7 +101,7 @@ under the License.
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleQueue"> <address name="exampleQueue">
<anycast> <anycast>
<queue name="exampleQueue"/> <queue name="exampleQueue"/>

View File

@ -16,10 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core"> <core xmlns="urn:activemq:core">
<bindings-directory>./data/bindings</bindings-directory> <bindings-directory>./data/bindings</bindings-directory>
@ -102,7 +100,7 @@ under the License.
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleQueue"> <address name="exampleQueue">
<anycast> <anycast>
<queue name="exampleQueue"/> <queue name="exampleQueue"/>

View File

@ -100,7 +100,23 @@ under the License.
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
</plugin>
</plugins> </plugins>
</build> </build>
<profiles>
</project> <profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>markdown-page-generator-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -16,11 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd"> <core xmlns="urn:activemq:core">
<core xmlns="urn:activemq:core">
<bindings-directory>${data.dir}/server0/data/messaging/bindings</bindings-directory> <bindings-directory>${data.dir}/server0/data/messaging/bindings</bindings-directory>
@ -96,7 +93,7 @@ under the License.
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleQueue"> <address name="exampleQueue">
<anycast> <anycast>
<queue name="exampleQueue"/> <queue name="exampleQueue"/>

View File

@ -16,11 +16,8 @@ software distributed under the License is distributed on an
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--><configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> -->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd"> <core xmlns="urn:activemq:core">
<core xmlns="urn:activemq:core">
<bindings-directory>${data.dir}/server0/data/messaging/bindings</bindings-directory> <bindings-directory>${data.dir}/server0/data/messaging/bindings</bindings-directory>
@ -96,7 +93,7 @@ under the License.
</security-setting> </security-setting>
</security-settings> </security-settings>
<addresses> <addresses>
<address name="exampleQueue"> <address name="exampleQueue">
<anycast> <anycast>
<queue name="exampleQueue"/> <queue name="exampleQueue"/>

View File

@ -120,7 +120,23 @@ under the License.
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
</plugin>
</plugins> </plugins>
</build> </build>
<profiles>
</project> <profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>markdown-page-generator-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -120,7 +120,23 @@ under the License.
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
</plugin>
</plugins> </plugins>
</build> </build>
<profiles>
</project> <profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>markdown-page-generator-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -106,7 +106,23 @@ under the License.
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
</plugin>
</plugins> </plugins>
</build> </build>
<profiles>
</project> <profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>markdown-page-generator-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -1,157 +0,0 @@
<!--
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 Failover Without Transactions 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 Failover Without Transactions Example</h1>
<pre>To run the example, simply type <b>mvn verify</b> from this directory.</pre>
<p>This example demonstrates two servers coupled as a live-backup pair for high availability (HA), and a client
connection failing over from live to backup when the live server is crashed.</p>
<p>Failover behavior differs whether the JMS session is transacted or not.</p>
<p>When a <em>non-transacted</em> JMS session is used, once and only once delivery is not guaranteed
and it is possible some messages will be lost or delivered twice, depending when the failover to the backup server occurs.</p>
<p>It is up to the client to deal with such cases. To ensure once and only once delivery, the client must
use transacted JMS sessions (as shown in the example for <a href="../transaction-failover/readme.html">failover with transactions</a>).</p>
<p>For more information on ActiveMQ Artemis failover and HA, and clustering in general, please see the clustering
section of the user manual.</p>
<h2>Example step-by-step</h2>
<p>In this example, the live server is server 1, and the backup server is server 0</p>
<p>The connection will initially be created to server1, server 1 will crash, and the client will carry on
seamlessly on server 0, the backup server.</p>
<ol>
<li>Get an initial context for looking up JNDI from server #1.</li>
<pre class="prettyprint">
initialContext = getContext(1);
</pre>
<li>Look up the JMS resources from JNDI on server #1.</li>
<pre class="prettyprint">
Queue queue = (Queue)initialContext.lookup("/queue/exampleQueue");
ConnectionFactory connectionFactory = (ConnectionFactory)initialContext.lookup("/ConnectionFactory");
</pre>
<li>Create a JMS Connection</li>
<pre class="prettyprint">
connection = connectionFactory.createConnection();
</pre>
<li>Create a JMS <em>non-transacted</em> Session with client acknowledgement</li>
<pre class="prettyprint">
Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
</pre>
<li>Start the connection to ensure delivery occurs</li>
<pre class="prettyprint">
connection.start();
</pre>
<li>Create a JMS MessageProducer and MessageConsumer</li>
<pre class="prettyprint">
MessageProducer producer = session.createProducer(queue);
MessageConsumer consumer = session.createConsumer(queue);
</pre>
<li>Send some messages to server #1</li>
<pre class="prettyprint">
for (int i = 0; i &lt; numMessages; i++)
{
TextMessage message = session.createTextMessage("This is text message " + i);
producer.send(message);
System.out.println("Sent message: " + message.getText());
}
</pre>
<li>Receive and acknowledge half of the sent messages</li>
<pre class="prettyprint">
TextMessage message0 = null;
for (int i = 0; i &lt; numMessages / 2; i++)
{
message0 = (TextMessage)consumer.receive(5000);
System.out.println("Got message: " + message0.getText());
}
message0.acknowledge();
</pre>
<li>Receive the second half of the sent messages but <em>do not acknowledge them yet</em></li>
<pre class="prettyprint">
for (int i = numMessages / 2; i &lt; numMessages; i++)
{
message0 = (TextMessage)consumer.receive(5000);
System.out.println("Got message: " + message0.getText());
}
</pre>
<li>Crash server #1, the live server, and wait a little while to make sure it has really crashed.</li>
<pre class="prettyprint">
killServer(1);
Thread.sleep(2000);
</pre>
<li>Acknowledging the second half of the sent messages will fail as failover to the backup server has occurred</li>
<pre class="prettyprint">
try
{
message0.acknowledge();
}
catch (JMSException e)
{
System.err.println("Got exception while acknowledging message: " + e.getMessage());
}
</pre>
<li>Consume again the second half of the messages againg. Note that they are not considered as redelivered</li>
<pre class="prettyprint">
for (int i = numMessages / 2; i &lt; numMessages; i++)
{
message0 = (TextMessage)consumer.receive(5000);
System.out.printf("Got message: %s (redelivered?: %s)\n", message0.getText(), message0.getJMSRedelivered());
}
message0.acknowledge();
</pre>
<li>And finally, <strong>always</strong> remember to close your resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
<pre class="prettyprint">
finally
{
if (connection != null)
{
connection.close();
}
if (initialContext != null)
{
initialContext.close();
}
}
</pre>
</ol>
</body>
</html>

View File

@ -0,0 +1,13 @@
# JMS Non Transaction Failover Example
To run the example, simply type **mvn verify** from this directory.
This example demonstrates two servers coupled as a live-backup pair for high availability (HA), and a client connection failing over from live to backup when the live broker is crashed.
Failover behavior differs whether the JMS session is transacted or not.
When a _non-transacted_ JMS session is used, once and only once delivery is not guaranteed and it is possible some messages will be lost or delivered twice, depending when the failover to the backup broker occurs.
It is up to the client to deal with such cases. To ensure once and only once delivery, the client must use transacted JMS sessions (as shown in the "transaction-failover" example).
For more information on ActiveMQ Artemis failover and HA, and clustering in general, please see the clustering section of the user manual.

View File

@ -102,6 +102,23 @@ under the License.
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
</plugin>
</plugins> </plugins>
</build> </build>
</project> <profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>markdown-page-generator-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -1,38 +0,0 @@
<!--
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 Failback using Static selectors 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 Multiple Failover using Replication Example</h1>
<pre>To run the example, simply type <b>mvn verify</b> from this directory.</pre>
<p>This example demonstrates three servers coupled as a live-backup-backup group for high availability (HA) using replication, and a client
connection failing over from live to backup when the live server is crashed and then to the second backup once the new live fails.</p>
<p>For more information on ActiveMQ Artemis failover and HA, and clustering in general, please see the clustering
section of the user manual.</p>
</body>
</html>

View File

@ -0,0 +1,7 @@
# JMS Replicated Failback Static Example
To run the example, simply type **mvn verify** from this directory.
This example is the same as the "replicated-failback" example but with a "static" clustering configuration (i.e. not using UDP multicast).
For more information on ActiveMQ Artemis failover and HA, and clustering in general, please see the clustering section of the user manual.

Some files were not shown because too many files have changed in this diff Show More