http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/ha/pom.xml ---------------------------------------------------------------------- diff --git a/examples/broker-features/ha/pom.xml b/examples/broker-features/ha/pom.xml deleted file mode 100644 index 016d9b1..0000000 --- a/examples/broker-features/ha/pom.xml +++ /dev/null @@ -1,95 +0,0 @@ -<?xml version='1.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. ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.activemq.examples.clustered</groupId> - <artifactId>broker-features</artifactId> - <version>1.0.1-SNAPSHOT</version> - </parent> - - <groupId>org.apache.activemq.examples.failover</groupId> - <artifactId>broker-failover</artifactId> - <packaging>pom</packaging> - <name>ActiveMQ Artemis Failover Examples</name> - - <!-- Properties --> - <properties> - <!-- - Explicitly declaring the source encoding eliminates the following - message: [WARNING] Using platform encoding (UTF-8 actually) to copy - filtered resources, i.e. build is platform dependent! - --> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <activemq.basedir>${project.basedir}/../../..</activemq.basedir> - </properties> - - <profiles> - <profile> - <id>release</id> - <modules> - <module>application-layer-failover</module> - <module>client-side-failoverlistener</module> - <module>colocated-failover</module> - <module>colocated-failover-scale-down</module> - <module>ha-policy-autobackup</module> - <module>multiple-failover</module> - <module>multiple-failover-failback</module> - <module>non-transaction-failover</module> - <module>replicated-failback</module> - <module>replicated-failback-static</module> - <module>replicated-multiple-failover</module> - <module>replicated-transaction-failover</module> - <module>scale-down</module> - <module>stop-server-failover</module> - <module>transaction-failover</module> - </modules> - </profile> - <profile> - <id>examples</id> - <modules> - <module>application-layer-failover</module> - <module>client-side-failoverlistener</module> - - <!-- ARTEMIS-197 FIX ME: - <module>colocated-failover</module> - <module>colocated-failover-scale-down</module> --> - - <module>ha-policy-autobackup</module> - <module>multiple-failover</module> - <module>multiple-failover-failback</module> - <module>non-transaction-failover</module> - - <!-- ARTEMIS-197 FIX ME: - <module>replicated-failback</module> - <module>replicated-failback-static</module> --> - - <module>replicated-multiple-failover</module> - <module>replicated-transaction-failover</module> - <module>scale-down</module> - <module>transaction-failover</module> - </modules> - </profile> - </profiles> - -</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/ha/replicated-failback-static/pom.xml ---------------------------------------------------------------------- diff --git a/examples/broker-features/ha/replicated-failback-static/pom.xml b/examples/broker-features/ha/replicated-failback-static/pom.xml deleted file mode 100644 index 91bb01e..0000000 --- a/examples/broker-features/ha/replicated-failback-static/pom.xml +++ /dev/null @@ -1,104 +0,0 @@ -<?xml version='1.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. ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.activemq.examples.failover</groupId> - <artifactId>broker-failover</artifactId> - <version>1.0.1-SNAPSHOT</version> - </parent> - - <artifactId>replicated-failback-static</artifactId> - <packaging>jar</packaging> - <name>ActiveMQ Artemis JMS Replicated Failback Static Example</name> - - <properties> - <activemq.basedir>${project.basedir}/../../../..</activemq.basedir> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-cli</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-jms-client</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-maven-plugin</artifactId> - <executions> - <execution> - <id>create0</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <instance>${basedir}/target/server0</instance> - <configuration>${basedir}/target/classes/activemq/server0</configuration> - <javaOptions>-Dudp-address=${udp-address}</javaOptions> - </configuration> - </execution> - <execution> - <id>create1</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <instance>${basedir}/target/server1</instance> - <configuration>${basedir}/target/classes/activemq/server1</configuration> - <javaOptions>-Dudp-address=${udp-address}</javaOptions> - </configuration> - </execution> - <execution> - <id>runClient</id> - <goals> - <goal>runClient</goal> - </goals> - <configuration> - <clientClass>org.apache.activemq.artemis.jms.example.ReplicatedFailbackStaticExample</clientClass> - <args> - <param>${basedir}/target/server0</param> - <param>${basedir}/target/server1</param> - </args> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.apache.activemq.examples.failover</groupId> - <artifactId>replicated-failback-static</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - </plugin> - </plugins> - </build> -</project> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/ha/replicated-failback-static/readme.html ---------------------------------------------------------------------- diff --git a/examples/broker-features/ha/replicated-failback-static/readme.html b/examples/broker-features/ha/replicated-failback-static/readme.html deleted file mode 100644 index cab789a..0000000 --- a/examples/broker-features/ha/replicated-failback-static/readme.html +++ /dev/null @@ -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> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/ha/replicated-failback-static/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackStaticExample.java ---------------------------------------------------------------------- diff --git a/examples/broker-features/ha/replicated-failback-static/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackStaticExample.java b/examples/broker-features/ha/replicated-failback-static/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackStaticExample.java deleted file mode 100644 index d2f74ba..0000000 --- a/examples/broker-features/ha/replicated-failback-static/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackStaticExample.java +++ /dev/null @@ -1,149 +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. - */ -package org.apache.activemq.artemis.jms.example; - -import org.apache.activemq.artemis.util.ServerUtil; - -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.JMSException; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.naming.InitialContext; - -/** - * Example of live and replicating backup pair. - * <p> - * After both servers are started, the live server is killed and the backup becomes active ("fails-over"). - * <p> - * Later the live server is restarted and takes back its position by asking the backup to stop ("fail-back"). - */ -public class ReplicatedFailbackStaticExample { - - private static Process server0; - - private static Process server1; - - public static void main(final String[] args) throws Exception { - final int numMessages = 30; - - Connection connection = null; - - InitialContext initialContext = null; - - try { - server0 = ServerUtil.startServer(args[0], ReplicatedFailbackStaticExample.class.getSimpleName() + "0", 0, 30000); - server1 = ServerUtil.startServer(args[1], ReplicatedFailbackStaticExample.class.getSimpleName() + "1", 1, 10000); - - // Step 1. Get an initial context for looking up JNDI from the server #1 - initialContext = new InitialContext(); - - // Step 2. Look up the JMS resources from JNDI - Queue queue = (Queue) initialContext.lookup("queue/exampleQueue"); - ConnectionFactory connectionFactory = (ConnectionFactory) initialContext.lookup("ConnectionFactory"); - - // Step 3. Create a JMS Connection - connection = connectionFactory.createConnection(); - - // Step 4. Create a *non-transacted* JMS Session with client acknowledgement - Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); - - // Step 5. Start the connection to ensure delivery occurs - connection.start(); - - // Step 6. Create a JMS MessageProducer and a MessageConsumer - MessageProducer producer = session.createProducer(queue); - MessageConsumer consumer = session.createConsumer(queue); - - // Step 7. Send some messages to server #1, the live server - 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()); - } - - // Step 8. Receive and acknowledge a third of the sent messages - TextMessage message0 = null; - for (int i = 0; i < numMessages / 3; i++) { - message0 = (TextMessage) consumer.receive(5000); - System.out.println("Got message: " + message0.getText()); - } - message0.acknowledge(); - - // Step 9. Receive the rest third of the sent messages but *do not* acknowledge them yet - for (int i = numMessages / 3; i < numMessages; i++) { - message0 = (TextMessage) consumer.receive(5000); - System.out.println("Got message: " + message0.getText()); - } - - // Step 10. Crash server #0, the live server, and wait a little while to make sure - // it has really crashed - ServerUtil.killServer(server0); - - // Step 11. Acknowledging the 2nd half of the sent messages will fail as failover to the - // backup server has occurred - try { - message0.acknowledge(); - } - catch (JMSException e) { - System.out.println("Got (the expected) exception while acknowledging message: " + e.getMessage()); - } - - // Step 12. Consume again the 2nd third of the messages again. Note that they are not considered as redelivered. - for (int i = numMessages / 3; i < (numMessages / 3) * 2; i++) { - message0 = (TextMessage) consumer.receive(5000); - System.out.printf("Got message: %s (redelivered?: %s)\n", message0.getText(), message0.getJMSRedelivered()); - } - message0.acknowledge(); - - server0 = ServerUtil.startServer(args[0], ReplicatedFailbackStaticExample.class.getSimpleName() + "0", 0, 10000); - - // Step 11. Acknowledging the 2nd half of the sent messages will fail as failover to the - // backup server has occurred - try { - message0.acknowledge(); - } - catch (JMSException e) { - System.err.println("Got exception while acknowledging message: " + e.getMessage()); - } - - // Step 12. Consume again the 2nd third of the messages again. Note that they are not considered as redelivered. - for (int i = (numMessages / 3) * 2; i < numMessages; i++) { - message0 = (TextMessage) consumer.receive(5000); - System.out.printf("Got message: %s (redelivered?: %s)\n", message0.getText(), message0.getJMSRedelivered()); - } - message0.acknowledge(); - } - finally { - // Step 13. Be sure to close our resources! - - if (connection != null) { - connection.close(); - } - - if (initialContext != null) { - initialContext.close(); - } - - ServerUtil.killServer(server0); - ServerUtil.killServer(server1); - } - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/ha/replicated-failback-static/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/broker-features/ha/replicated-failback-static/src/main/resources/activemq/server0/broker.xml b/examples/broker-features/ha/replicated-failback-static/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index f6fa349..0000000 --- a/examples/broker-features/ha/replicated-failback-static/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,87 +0,0 @@ -<?xml version='1.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. ---> - -<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns="urn:activemq" - xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> - - <jms xmlns="urn:activemq:jms"> - <!--the queue used by the example--> - <queue name="exampleQueue"/> - </jms> - - <core xmlns="urn:activemq:core"> - - <bindings-directory>./data/bindings</bindings-directory> - - <journal-directory>./data/journal</journal-directory> - - <large-messages-directory>./data/largemessages</large-messages-directory> - - <paging-directory>./data/paging</paging-directory> - - <cluster-user>exampleUser</cluster-user> - - <cluster-password>secret</cluster-password> - - <ha-policy> - <replication> - <master> - <!--we need this for auto failback--> - <check-for-live-server>true</check-for-live-server> - </master> - </replication> - </ha-policy> - - <connectors> - <connector name="netty-connector">tcp://localhost:61616</connector> - <connector name="netty-backup-connector">tcp://localhost:61617</connector> - </connectors> - - <!-- Acceptors --> - <acceptors> - <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor> - </acceptors> - - <cluster-connections> - <cluster-connection name="my-cluster"> - <address>jms</address> - <connector-ref>netty-connector</connector-ref> - <static-connectors> - <connector-ref>netty-backup-connector</connector-ref> - </static-connectors> - </cluster-connection> - </cluster-connections> - <!-- Other config --> - - <security-settings> - <!--security for example queue--> - <security-setting match="jms.queue.exampleQueue"> - <permission type="createDurableQueue" roles="guest"/> - <permission type="deleteDurableQueue" roles="guest"/> - <permission type="createNonDurableQueue" roles="guest"/> - <permission type="deleteNonDurableQueue" roles="guest"/> - <permission type="consume" roles="guest"/> - <permission type="send" roles="guest"/> - </security-setting> - </security-settings> - - </core> -</configuration> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/ha/replicated-failback-static/src/main/resources/activemq/server1/broker.xml ---------------------------------------------------------------------- diff --git a/examples/broker-features/ha/replicated-failback-static/src/main/resources/activemq/server1/broker.xml b/examples/broker-features/ha/replicated-failback-static/src/main/resources/activemq/server1/broker.xml deleted file mode 100644 index 9b89d80..0000000 --- a/examples/broker-features/ha/replicated-failback-static/src/main/resources/activemq/server1/broker.xml +++ /dev/null @@ -1,89 +0,0 @@ -<?xml version='1.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. ---> - -<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns="urn:activemq" - xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> - - <jms xmlns="urn:activemq:jms"> - <!--the queue used by the example--> - <queue name="exampleQueue"/> - </jms> - - <core xmlns="urn:activemq:core"> - - <bindings-directory>./data/bindings</bindings-directory> - - <journal-directory>./data/journal</journal-directory> - - <large-messages-directory>./data/largemessages</large-messages-directory> - - <paging-directory>./data/paging</paging-directory> - - <cluster-user>exampleUser</cluster-user> - - <cluster-password>secret</cluster-password> - - <ha-policy> - <replication> - <slave> - <allow-failback>true</allow-failback> - <!-- not needed but tells the backup not to restart after failback as there will be > 0 backups saved --> - <max-saved-replicated-journals-size>0</max-saved-replicated-journals-size> - </slave> - </replication> - </ha-policy> - - <!-- Connectors --> - <connectors> - <connector name="netty-live-connector">tcp://localhost:61616</connector> - <connector name="netty-connector">tcp://localhost:61617</connector> - </connectors> - - <!-- Acceptors --> - <acceptors> - <acceptor name="netty-acceptor">tcp://localhost:61617</acceptor> - </acceptors> - - <cluster-connections> - <cluster-connection name="my-cluster"> - <address>jms</address> - <connector-ref>netty-connector</connector-ref> - <static-connectors> - <connector-ref>netty-live-connector</connector-ref> - </static-connectors> - </cluster-connection> - </cluster-connections> - <!-- Other config --> - - <security-settings> - <!--security for example queue--> - <security-setting match="jms.queue.exampleQueue"> - <permission type="createDurableQueue" roles="guest"/> - <permission type="deleteDurableQueue" roles="guest"/> - <permission type="createNonDurableQueue" roles="guest"/> - <permission type="deleteNonDurableQueue" roles="guest"/> - <permission type="consume" roles="guest"/> - <permission type="send" roles="guest"/> - </security-setting> - </security-settings> - - </core> -</configuration> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/ha/replicated-failback-static/src/main/resources/jndi.properties ---------------------------------------------------------------------- diff --git a/examples/broker-features/ha/replicated-failback-static/src/main/resources/jndi.properties b/examples/broker-features/ha/replicated-failback-static/src/main/resources/jndi.properties deleted file mode 100644 index 7f7a19f..0000000 --- a/examples/broker-features/ha/replicated-failback-static/src/main/resources/jndi.properties +++ /dev/null @@ -1,20 +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. - -java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory -connectionFactory.ConnectionFactory=tcp://localhost:61616?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1 -queue.queue/exampleQueue=exampleQueue http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/ha/replicated-failback/pom.xml ---------------------------------------------------------------------- diff --git a/examples/broker-features/ha/replicated-failback/pom.xml b/examples/broker-features/ha/replicated-failback/pom.xml deleted file mode 100644 index d996718..0000000 --- a/examples/broker-features/ha/replicated-failback/pom.xml +++ /dev/null @@ -1,103 +0,0 @@ -<?xml version='1.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. ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.activemq.examples.failover</groupId> - <artifactId>broker-failover</artifactId> - <version>1.0.1-SNAPSHOT</version> - </parent> - - <artifactId>replicated-failback</artifactId> - <packaging>jar</packaging> - <name>ActiveMQ Artemis JMS Replicated Failback Example</name> - - <properties> - <activemq.basedir>${project.basedir}/../../../..</activemq.basedir> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-cli</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>geronimo-jms_2.0_spec</artifactId> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-maven-plugin</artifactId> - <executions> - <execution> - <id>create0</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <instance>${basedir}/target/server0</instance> - <configuration>${basedir}/target/classes/activemq/server0</configuration> - <javaOptions>-Dudp-address=${udp-address}</javaOptions> - </configuration> - </execution> - <execution> - <id>create1</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <instance>${basedir}/target/server1</instance> - <configuration>${basedir}/target/classes/activemq/server1</configuration> - <javaOptions>-Dudp-address=${udp-address}</javaOptions> - </configuration> - </execution> - <execution> - <id>runClient</id> - <goals> - <goal>runClient</goal> - </goals> - <configuration> - <clientClass>org.apache.activemq.artemis.jms.example.ReplicatedFailbackExample</clientClass> - <args> - <param>${basedir}/target/server0</param> - <param>${basedir}/target/server1</param> - </args> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.apache.activemq.examples.failover</groupId> - <artifactId>replicated-failback</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - </plugin> - </plugins> - </build> -</project> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/ha/replicated-failback/readme.html ---------------------------------------------------------------------- diff --git a/examples/broker-features/ha/replicated-failback/readme.html b/examples/broker-features/ha/replicated-failback/readme.html deleted file mode 100644 index 4e53739..0000000 --- a/examples/broker-features/ha/replicated-failback/readme.html +++ /dev/null @@ -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 Multiple Failover using Replication 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> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/ha/replicated-failback/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackExample.java ---------------------------------------------------------------------- diff --git a/examples/broker-features/ha/replicated-failback/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackExample.java b/examples/broker-features/ha/replicated-failback/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackExample.java deleted file mode 100644 index 29ae381..0000000 --- a/examples/broker-features/ha/replicated-failback/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedFailbackExample.java +++ /dev/null @@ -1,149 +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. - */ -package org.apache.activemq.artemis.jms.example; - -import org.apache.activemq.artemis.util.ServerUtil; - -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.JMSException; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.naming.InitialContext; - -/** - * Example of live and replicating backup pair. - * <p> - * After both servers are started, the live server is killed and the backup becomes active ("fails-over"). - * <p> - * Later the live server is restarted and takes back its position by asking the backup to stop ("fail-back"). - */ -public class ReplicatedFailbackExample { - - private static Process server0; - - private static Process server1; - - public static void main(final String[] args) throws Exception { - final int numMessages = 30; - - Connection connection = null; - - InitialContext initialContext = null; - - try { - server0 = ServerUtil.startServer(args[0], ReplicatedFailbackExample.class.getSimpleName() + "0", 0, 30000); - server1 = ServerUtil.startServer(args[1], ReplicatedFailbackExample.class.getSimpleName() + "1", 1, 10000); - - // Step 1. Get an initial context for looking up JNDI from the server #1 - initialContext = new InitialContext(); - - // Step 2. Look up the JMS resources from JNDI - Queue queue = (Queue) initialContext.lookup("queue/exampleQueue"); - ConnectionFactory connectionFactory = (ConnectionFactory) initialContext.lookup("ConnectionFactory"); - - // Step 3. Create a JMS Connection - connection = connectionFactory.createConnection(); - - // Step 4. Create a *non-transacted* JMS Session with client acknowledgement - Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); - - // Step 5. Start the connection to ensure delivery occurs - connection.start(); - - // Step 6. Create a JMS MessageProducer and a MessageConsumer - MessageProducer producer = session.createProducer(queue); - MessageConsumer consumer = session.createConsumer(queue); - - // Step 7. Send some messages to server #1, the live server - 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()); - } - - // Step 8. Receive and acknowledge a third of the sent messages - TextMessage message0 = null; - for (int i = 0; i < numMessages / 3; i++) { - message0 = (TextMessage) consumer.receive(5000); - System.out.println("Got message: " + message0.getText()); - } - message0.acknowledge(); - - // Step 9. Receive the rest third of the sent messages but *do not* acknowledge them yet - for (int i = numMessages / 3; i < numMessages; i++) { - message0 = (TextMessage) consumer.receive(5000); - System.out.println("Got message: " + message0.getText()); - } - - // Step 10. Crash server #0, the live server, and wait a little while to make sure - // it has really crashed - ServerUtil.killServer(server0); - - // Step 11. Acknowledging the 2nd half of the sent messages will fail as failover to the - // backup server has occurred - try { - message0.acknowledge(); - } - catch (JMSException e) { - System.out.println("Got (the expected) exception while acknowledging message: " + e.getMessage()); - } - - // Step 12. Consume again the 2nd third of the messages again. Note that they are not considered as redelivered. - for (int i = numMessages / 3; i < (numMessages / 3) * 2; i++) { - message0 = (TextMessage) consumer.receive(5000); - System.out.printf("Got message: %s (redelivered?: %s)\n", message0.getText(), message0.getJMSRedelivered()); - } - message0.acknowledge(); - - server0 = ServerUtil.startServer(args[0], ReplicatedFailbackExample.class.getSimpleName() + "0", 0, 10000); - - // Step 11. Acknowledging the 2nd half of the sent messages will fail as failover to the - // backup server has occurred - try { - message0.acknowledge(); - } - catch (JMSException e) { - System.err.println("Got exception while acknowledging message: " + e.getMessage()); - } - - // Step 12. Consume again the 2nd third of the messages again. Note that they are not considered as redelivered. - for (int i = (numMessages / 3) * 2; i < numMessages; i++) { - message0 = (TextMessage) consumer.receive(5000); - System.out.printf("Got message: %s (redelivered?: %s)\n", message0.getText(), message0.getJMSRedelivered()); - } - message0.acknowledge(); - } - finally { - // Step 13. Be sure to close our resources! - - if (connection != null) { - connection.close(); - } - - if (initialContext != null) { - initialContext.close(); - } - - ServerUtil.killServer(server0); - ServerUtil.killServer(server1); - } - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/ha/replicated-failback/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/broker-features/ha/replicated-failback/src/main/resources/activemq/server0/broker.xml b/examples/broker-features/ha/replicated-failback/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index c7f4783..0000000 --- a/examples/broker-features/ha/replicated-failback/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,101 +0,0 @@ -<?xml version='1.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. ---> - -<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns="urn:activemq" - xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> - - <jms xmlns="urn:activemq:jms"> - <!--the queue used by the example--> - <queue name="exampleQueue"/> - </jms> - - <core xmlns="urn:activemq:core"> - - <bindings-directory>./data/bindings</bindings-directory> - - <journal-directory>./data/journal</journal-directory> - - <large-messages-directory>./data/largemessages</large-messages-directory> - - <paging-directory>./data/paging</paging-directory> - - <cluster-user>exampleUser</cluster-user> - - <cluster-password>secret</cluster-password> - - <ha-policy> - <replication> - <master> - <!--we need this for auto failback--> - <check-for-live-server>true</check-for-live-server> - </master> - </replication> - </ha-policy> - - <connectors> - <connector name="netty-connector">tcp://localhost:61616</connector> - </connectors> - - <!-- Acceptors --> - <acceptors> - <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor> - </acceptors> - - <broadcast-groups> - <broadcast-group name="bg-group1"> - <group-address>${udp-address:231.7.7.7}</group-address> - <group-port>9876</group-port> - <broadcast-period>1000</broadcast-period> - <connector-ref>netty-connector</connector-ref> - </broadcast-group> - </broadcast-groups> - - <discovery-groups> - <discovery-group name="dg-group1"> - <group-address>${udp-address:231.7.7.7}</group-address> - <group-port>9876</group-port> - <refresh-timeout>5000</refresh-timeout> - </discovery-group> - </discovery-groups> - - <cluster-connections> - <cluster-connection name="my-cluster"> - <address>jms</address> - <connector-ref>netty-connector</connector-ref> - <discovery-group-ref discovery-group-name="dg-group1"/> - </cluster-connection> - </cluster-connections> - <!-- Other config --> - - <security-settings> - <!--security for example queue--> - <security-setting match="jms.queue.exampleQueue"> - <permission type="createDurableQueue" roles="guest"/> - <permission type="deleteDurableQueue" roles="guest"/> - <permission type="createNonDurableQueue" roles="guest"/> - <permission type="deleteNonDurableQueue" roles="guest"/> - <permission type="consume" roles="guest"/> - <permission type="send" roles="guest"/> - </security-setting> - </security-settings> - - </core> -</configuration> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/ha/replicated-failback/src/main/resources/activemq/server1/broker.xml ---------------------------------------------------------------------- diff --git a/examples/broker-features/ha/replicated-failback/src/main/resources/activemq/server1/broker.xml b/examples/broker-features/ha/replicated-failback/src/main/resources/activemq/server1/broker.xml deleted file mode 100644 index da5a656..0000000 --- a/examples/broker-features/ha/replicated-failback/src/main/resources/activemq/server1/broker.xml +++ /dev/null @@ -1,102 +0,0 @@ -<?xml version='1.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. ---> - -<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns="urn:activemq" - xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> - - <jms xmlns="urn:activemq:jms"> - <!--the queue used by the example--> - <queue name="exampleQueue"/> - </jms> - - <core xmlns="urn:activemq:core"> - - <bindings-directory>./data/bindings</bindings-directory> - - <journal-directory>./data/journal</journal-directory> - - <large-messages-directory>./data/largemessages</large-messages-directory> - - <paging-directory>./data/paging</paging-directory> - - <cluster-user>exampleUser</cluster-user> - - <cluster-password>secret</cluster-password> - - <ha-policy> - <replication> - <slave> - <allow-failback>true</allow-failback> - </slave> - </replication> - </ha-policy> - - <!-- Connectors --> - <connectors> - <connector name="netty-live-connector">tcp://localhost:61616</connector> - <connector name="netty-connector">tcp://localhost:61617</connector> - </connectors> - - <!-- Acceptors --> - <acceptors> - <acceptor name="netty-acceptor">tcp://localhost:61617</acceptor> - </acceptors> - - <broadcast-groups> - <broadcast-group name="bg-group1"> - <group-address>${udp-address:231.7.7.7}</group-address> - <group-port>9876</group-port> - <broadcast-period>1000</broadcast-period> - <connector-ref>netty-connector</connector-ref> - </broadcast-group> - </broadcast-groups> - - <discovery-groups> - <discovery-group name="dg-group1"> - <group-address>${udp-address:231.7.7.7}</group-address> - <group-port>9876</group-port> - <refresh-timeout>5000</refresh-timeout> - </discovery-group> - </discovery-groups> - - <cluster-connections> - <cluster-connection name="my-cluster"> - <address>jms</address> - <connector-ref>netty-connector</connector-ref> - <discovery-group-ref discovery-group-name="dg-group1"/> - </cluster-connection> - </cluster-connections> - <!-- Other config --> - - <security-settings> - <!--security for example queue--> - <security-setting match="jms.queue.exampleQueue"> - <permission type="createDurableQueue" roles="guest"/> - <permission type="deleteDurableQueue" roles="guest"/> - <permission type="createNonDurableQueue" roles="guest"/> - <permission type="deleteNonDurableQueue" roles="guest"/> - <permission type="consume" roles="guest"/> - <permission type="send" roles="guest"/> - </security-setting> - </security-settings> - - </core> -</configuration> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/ha/replicated-failback/src/main/resources/jndi.properties ---------------------------------------------------------------------- diff --git a/examples/broker-features/ha/replicated-failback/src/main/resources/jndi.properties b/examples/broker-features/ha/replicated-failback/src/main/resources/jndi.properties deleted file mode 100644 index 7f7a19f..0000000 --- a/examples/broker-features/ha/replicated-failback/src/main/resources/jndi.properties +++ /dev/null @@ -1,20 +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. - -java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory -connectionFactory.ConnectionFactory=tcp://localhost:61616?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1 -queue.queue/exampleQueue=exampleQueue http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/ha/replicated-multiple-failover/pom.xml ---------------------------------------------------------------------- diff --git a/examples/broker-features/ha/replicated-multiple-failover/pom.xml b/examples/broker-features/ha/replicated-multiple-failover/pom.xml deleted file mode 100644 index 23dcfd7..0000000 --- a/examples/broker-features/ha/replicated-multiple-failover/pom.xml +++ /dev/null @@ -1,118 +0,0 @@ -<?xml version='1.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. ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.activemq.examples.failover</groupId> - <artifactId>broker-failover</artifactId> - <version>1.0.1-SNAPSHOT</version> - </parent> - - <artifactId>replicated-multiple-failover</artifactId> - <packaging>jar</packaging> - <name>ActiveMQ Artemis JMS Replicated Multiple Failover Example</name> - - <properties> - <activemq.basedir>${project.basedir}/../../../..</activemq.basedir> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-cli</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-jms-client</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-maven-plugin</artifactId> - <executions> - <execution> - <id>create0</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <instance>${basedir}/target/server0</instance> - <configuration>${basedir}/target/classes/activemq/server0</configuration> - <javaOptions>-Dudp-address=${udp-address}</javaOptions> - </configuration> - </execution> - <execution> - <id>create1</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <instance>${basedir}/target/server1</instance> - <configuration>${basedir}/target/classes/activemq/server1</configuration> - <javaOptions>-Dudp-address=${udp-address}</javaOptions> - </configuration> - </execution> - <execution> - <id>create2</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <instance>${basedir}/target/server2</instance> - <configuration>${basedir}/target/classes/activemq/server2</configuration> - <javaOptions>-Dudp-address=${udp-address}</javaOptions> - </configuration> - </execution> - <execution> - <id>runClient</id> - <goals> - <goal>runClient</goal> - </goals> - <configuration> - <clientClass>org.apache.activemq.artemis.jms.example.ReplicatedMultipleFailoverExample - </clientClass> - <args> - <param>${basedir}/target/server0</param> - <param>${basedir}/target/server1</param> - <param>${basedir}/target/server2</param> - </args> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.apache.activemq.examples.failover</groupId> - <artifactId>replicated-multiple-failover</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - </plugin> - </plugins> - </build> - -</project> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/ha/replicated-multiple-failover/readme.html ---------------------------------------------------------------------- diff --git a/examples/broker-features/ha/replicated-multiple-failover/readme.html b/examples/broker-features/ha/replicated-multiple-failover/readme.html deleted file mode 100644 index da37085..0000000 --- a/examples/broker-features/ha/replicated-multiple-failover/readme.html +++ /dev/null @@ -1,45 +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 Multiple Failover using Replication 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> - - <h2>Example step-by-step</h2> - <p><i>To run the example, simply type <code>mvn verify -Pexample</code> from this directory</i></p> - <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> - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/ha/replicated-multiple-failover/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedMultipleFailoverExample.java ---------------------------------------------------------------------- diff --git a/examples/broker-features/ha/replicated-multiple-failover/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedMultipleFailoverExample.java b/examples/broker-features/ha/replicated-multiple-failover/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedMultipleFailoverExample.java deleted file mode 100644 index 491d792..0000000 --- a/examples/broker-features/ha/replicated-multiple-failover/src/main/java/org/apache/activemq/artemis/jms/example/ReplicatedMultipleFailoverExample.java +++ /dev/null @@ -1,149 +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. - */ -package org.apache.activemq.artemis.jms.example; - -import org.apache.activemq.artemis.util.ServerUtil; - -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.JMSException; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.naming.InitialContext; - -public class ReplicatedMultipleFailoverExample { - - private static Process server0; - - private static Process server1; - - private static Process server2; - - public static void main(final String[] args) throws Exception { - final int numMessages = 30; - - Connection connection = null; - - InitialContext initialContext = null; - - try { - server0 = ServerUtil.startServer(args[0], ReplicatedMultipleFailoverExample.class.getSimpleName() + "0", 0, 5000); - server1 = ServerUtil.startServer(args[1], ReplicatedMultipleFailoverExample.class.getSimpleName() + "1", 1, 5000); - server2 = ServerUtil.startServer(args[2], ReplicatedMultipleFailoverExample.class.getSimpleName() + "2", 2, 5000); - - Process[] processes = new Process[]{server0, server1, server2}; - - // Step 1. Get an initial context for looking up JNDI from the server #1 - initialContext = new InitialContext(); - - // Step 2. Look up the JMS resources from JNDI - Queue queue = (Queue) initialContext.lookup("queue/exampleQueue"); - ConnectionFactory connectionFactory = (ConnectionFactory) initialContext.lookup("ConnectionFactory"); - - // Step 3. Create a JMS Connection - connection = connectionFactory.createConnection(); - - // Step 4. Create a *non-transacted* JMS Session with client acknowledgement - Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); - - // Step 5. Start the connection to ensure delivery occurs - connection.start(); - - // Step 6. Create a JMS MessageProducer and a MessageConsumer - MessageProducer producer = session.createProducer(queue); - MessageConsumer consumer = session.createConsumer(queue); - - // Step 7. Send some messages to server #1, the live server - 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()); - } - - // Step 8. Receive and acknowledge a third of the sent messages - TextMessage message0 = null; - for (int i = 0; i < numMessages / 3; i++) { - message0 = (TextMessage) consumer.receive(5000); - System.out.println("Got message: " + message0.getText()); - } - message0.acknowledge(); - - // Step 9. Receive the rest third of the sent messages but *do not* acknowledge them yet - for (int i = numMessages / 3; i < numMessages; i++) { - message0 = (TextMessage) consumer.receive(5000); - System.out.println("Got message: " + message0.getText()); - } - - // Step 10. Crash server #0, the live server, and wait a little while to make sure - // it has really crashed - ServerUtil.killServer(server0); - Thread.sleep(5000); - - // Step 11. Acknowledging the 2nd half of the sent messages will fail as failover to the - // backup server has occurred - try { - message0.acknowledge(); - } - catch (JMSException e) { - System.err.println("Got exception while acknowledging message: " + e.getMessage()); - } - - // Step 12. Consume again the 2nd third of the messages again. Note that they are not considered as redelivered. - for (int i = numMessages / 3; i < (numMessages / 3) * 2; i++) { - message0 = (TextMessage) consumer.receive(5000); - System.out.printf("Got message: %s (redelivered?: %s)%n", message0.getText(), message0.getJMSRedelivered()); - } - message0.acknowledge(); - - ServerUtil.killServer(processes[ServerUtil.getServer(connection)]); - - // Step 11. Acknowledging the 2nd half of the sent messages will fail as failover to the - // backup server has occurred - try { - message0.acknowledge(); - } - catch (JMSException e) { - System.err.println("Got exception while acknowledging message: " + e.getMessage()); - } - - // Step 12. Consume again the 2nd third of the messages again. Note that they are not considered as redelivered. - for (int i = (numMessages / 3) * 2; i < numMessages; i++) { - message0 = (TextMessage) consumer.receive(5000); - System.out.printf("Got message: %s (redelivered?: %s)%n", message0.getText(), message0.getJMSRedelivered()); - } - message0.acknowledge(); - } - finally { - // Step 13. Be sure to close our resources! - - if (connection != null) { - connection.close(); - } - - if (initialContext != null) { - initialContext.close(); - } - - ServerUtil.killServer(server0); - ServerUtil.killServer(server1); - ServerUtil.killServer(server2); - } - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/ha/replicated-multiple-failover/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/broker-features/ha/replicated-multiple-failover/src/main/resources/activemq/server0/broker.xml b/examples/broker-features/ha/replicated-multiple-failover/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 43f1693..0000000 --- a/examples/broker-features/ha/replicated-multiple-failover/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,95 +0,0 @@ -<?xml version='1.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. ---> - -<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns="urn:activemq" - xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> - - <jms xmlns="urn:activemq:jms"> - <!--the queue used by the example--> - <queue name="exampleQueue"/> - </jms> - - <core xmlns="urn:activemq:core"> - - <bindings-directory>./data/bindings</bindings-directory> - - <journal-directory>./data/journal</journal-directory> - - <large-messages-directory>./data/largemessages</large-messages-directory> - - <paging-directory>./data/paging</paging-directory> - - <ha-policy> - <replication> - <master/> - </replication> - </ha-policy> - - <!-- Connectors --> - <connectors> - <connector name="netty-connector">tcp://localhost:61616</connector> - </connectors> - - <!-- Acceptors --> - <acceptors> - <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor> - </acceptors> - - <broadcast-groups> - <broadcast-group name="bg-group1"> - <group-address>${udp-address:231.7.7.7}</group-address> - <group-port>9876</group-port> - <broadcast-period>1000</broadcast-period> - <connector-ref>netty-connector</connector-ref> - </broadcast-group> - </broadcast-groups> - - <discovery-groups> - <discovery-group name="dg-group1"> - <group-address>${udp-address:231.7.7.7}</group-address> - <group-port>9876</group-port> - <refresh-timeout>60000</refresh-timeout> - </discovery-group> - </discovery-groups> - - <cluster-connections> - <cluster-connection name="my-cluster"> - <address>jms</address> - <connector-ref>netty-connector</connector-ref> - <discovery-group-ref discovery-group-name="dg-group1"/> - </cluster-connection> - </cluster-connections> - <!-- Other config --> - - <security-settings> - <!--security for example queue--> - <security-setting match="jms.queue.exampleQueue"> - <permission type="createDurableQueue" roles="guest"/> - <permission type="deleteDurableQueue" roles="guest"/> - <permission type="createNonDurableQueue" roles="guest"/> - <permission type="deleteNonDurableQueue" roles="guest"/> - <permission type="consume" roles="guest"/> - <permission type="send" roles="guest"/> - </security-setting> - </security-settings> - - </core> -</configuration> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/ha/replicated-multiple-failover/src/main/resources/activemq/server1/broker.xml ---------------------------------------------------------------------- diff --git a/examples/broker-features/ha/replicated-multiple-failover/src/main/resources/activemq/server1/broker.xml b/examples/broker-features/ha/replicated-multiple-failover/src/main/resources/activemq/server1/broker.xml deleted file mode 100644 index 7f17fb8..0000000 --- a/examples/broker-features/ha/replicated-multiple-failover/src/main/resources/activemq/server1/broker.xml +++ /dev/null @@ -1,95 +0,0 @@ -<?xml version='1.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. ---> - -<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns="urn:activemq" - xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> - - <jms xmlns="urn:activemq:jms"> - <!--the queue used by the example--> - <queue name="exampleQueue"/> - </jms> - - <core xmlns="urn:activemq:core"> - - <bindings-directory>./data/bindings</bindings-directory> - - <journal-directory>./data/journal</journal-directory> - - <large-messages-directory>./data/largemessages</large-messages-directory> - - <paging-directory>./data/paging</paging-directory> - - <ha-policy> - <replication> - <slave/> - </replication> - </ha-policy> - - <!-- Connectors --> - <connectors> - <connector name="netty-connector">tcp://localhost:61617</connector> - </connectors> - - <!-- Acceptors --> - <acceptors> - <acceptor name="netty-acceptor">tcp://localhost:61617</acceptor> - </acceptors> - - <broadcast-groups> - <broadcast-group name="bg-group1"> - <group-address>${udp-address:231.7.7.7}</group-address> - <group-port>9876</group-port> - <broadcast-period>1000</broadcast-period> - <connector-ref>netty-connector</connector-ref> - </broadcast-group> - </broadcast-groups> - - <discovery-groups> - <discovery-group name="dg-group1"> - <group-address>${udp-address:231.7.7.7}</group-address> - <group-port>9876</group-port> - <refresh-timeout>60000</refresh-timeout> - </discovery-group> - </discovery-groups> - - <cluster-connections> - <cluster-connection name="my-cluster"> - <address>jms</address> - <connector-ref>netty-connector</connector-ref> - <discovery-group-ref discovery-group-name="dg-group1"/> - </cluster-connection> - </cluster-connections> - <!-- Other config --> - - <security-settings> - <!--security for example queue--> - <security-setting match="jms.queue.exampleQueue"> - <permission type="createDurableQueue" roles="guest"/> - <permission type="deleteDurableQueue" roles="guest"/> - <permission type="createNonDurableQueue" roles="guest"/> - <permission type="deleteNonDurableQueue" roles="guest"/> - <permission type="consume" roles="guest"/> - <permission type="send" roles="guest"/> - </security-setting> - </security-settings> - - </core> -</configuration> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/ha/replicated-multiple-failover/src/main/resources/activemq/server2/broker.xml ---------------------------------------------------------------------- diff --git a/examples/broker-features/ha/replicated-multiple-failover/src/main/resources/activemq/server2/broker.xml b/examples/broker-features/ha/replicated-multiple-failover/src/main/resources/activemq/server2/broker.xml deleted file mode 100644 index c5f06cc..0000000 --- a/examples/broker-features/ha/replicated-multiple-failover/src/main/resources/activemq/server2/broker.xml +++ /dev/null @@ -1,95 +0,0 @@ -<?xml version='1.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. ---> - -<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns="urn:activemq" - xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> - - <jms xmlns="urn:activemq:jms"> - <!--the queue used by the example--> - <queue name="exampleQueue"/> - </jms> - - <core xmlns="urn:activemq:core"> - - <bindings-directory>./data/bindings</bindings-directory> - - <journal-directory>./data/journal</journal-directory> - - <large-messages-directory>./data/largemessages</large-messages-directory> - - <paging-directory>./data/paging</paging-directory> - - <ha-policy> - <replication> - <slave/> - </replication> - </ha-policy> - - <!-- Connectors --> - <connectors> - <connector name="netty-connector">tcp://localhost:61618</connector> - </connectors> - - <!-- Acceptors --> - <acceptors> - <acceptor name="netty-acceptor">tcp://localhost:61618</acceptor> - </acceptors> - - <broadcast-groups> - <broadcast-group name="bg-group1"> - <group-address>${udp-address:231.7.7.7}</group-address> - <group-port>9876</group-port> - <broadcast-period>1000</broadcast-period> - <connector-ref>netty-connector</connector-ref> - </broadcast-group> - </broadcast-groups> - - <discovery-groups> - <discovery-group name="dg-group1"> - <group-address>${udp-address:231.7.7.7}</group-address> - <group-port>9876</group-port> - <refresh-timeout>60000</refresh-timeout> - </discovery-group> - </discovery-groups> - - <cluster-connections> - <cluster-connection name="my-cluster"> - <address>jms</address> - <connector-ref>netty-connector</connector-ref> - <discovery-group-ref discovery-group-name="dg-group1"/> - </cluster-connection> - </cluster-connections> - <!-- Other config --> - - <security-settings> - <!--security for example queue--> - <security-setting match="jms.queue.exampleQueue"> - <permission type="createDurableQueue" roles="guest"/> - <permission type="deleteDurableQueue" roles="guest"/> - <permission type="createNonDurableQueue" roles="guest"/> - <permission type="deleteNonDurableQueue" roles="guest"/> - <permission type="consume" roles="guest"/> - <permission type="send" roles="guest"/> - </security-setting> - </security-settings> - - </core> -</configuration> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/ha/replicated-multiple-failover/src/main/resources/jndi.properties ---------------------------------------------------------------------- diff --git a/examples/broker-features/ha/replicated-multiple-failover/src/main/resources/jndi.properties b/examples/broker-features/ha/replicated-multiple-failover/src/main/resources/jndi.properties deleted file mode 100644 index 7f7a19f..0000000 --- a/examples/broker-features/ha/replicated-multiple-failover/src/main/resources/jndi.properties +++ /dev/null @@ -1,20 +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. - -java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory -connectionFactory.ConnectionFactory=tcp://localhost:61616?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1 -queue.queue/exampleQueue=exampleQueue http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/ha/replicated-transaction-failover/pom.xml ---------------------------------------------------------------------- diff --git a/examples/broker-features/ha/replicated-transaction-failover/pom.xml b/examples/broker-features/ha/replicated-transaction-failover/pom.xml deleted file mode 100644 index 4c1839e..0000000 --- a/examples/broker-features/ha/replicated-transaction-failover/pom.xml +++ /dev/null @@ -1,104 +0,0 @@ -<?xml version='1.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. ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.activemq.examples.failover</groupId> - <artifactId>broker-failover</artifactId> - <version>1.0.1-SNAPSHOT</version> - </parent> - - <artifactId>replicated-transaction-failover</artifactId> - <packaging>jar</packaging> - <name>ActiveMQ Artemis JMS Replicated Transaction Failover Example</name> - - <properties> - <activemq.basedir>${project.basedir}/../../../..</activemq.basedir> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-cli</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-jms-client</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-maven-plugin</artifactId> - <executions> - <execution> - <id>create0</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <instance>${basedir}/target/server0</instance> - <configuration>${basedir}/target/classes/activemq/server0</configuration> - <javaOptions>-Dudp-address=${udp-address}</javaOptions> - </configuration> - </execution> - <execution> - <id>create1</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <instance>${basedir}/target/server1</instance> - <configuration>${basedir}/target/classes/activemq/server1</configuration> - <javaOptions>-Dudp-address=${udp-address}</javaOptions> - </configuration> - </execution> - <execution> - <id>runClient</id> - <goals> - <goal>runClient</goal> - </goals> - <configuration> - <clientClass>org.apache.activemq.artemis.jms.example.ReplicatedTransactionFailoverExample - </clientClass> - <args> - <param>${basedir}/target/server0</param> - <param>${basedir}/target/server1</param> - </args> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.apache.activemq.examples.failover</groupId> - <artifactId>replicated-transaction-failover</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - </plugin> - </plugins> - </build> -</project>