http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/clustered-static-oneway/src/main/resources/activemq/server1/broker.xml ---------------------------------------------------------------------- diff --git a/examples/jms/clustered-static-oneway/src/main/resources/activemq/server1/broker.xml b/examples/jms/clustered-static-oneway/src/main/resources/activemq/server1/broker.xml deleted file mode 100644 index 1464ea9..0000000 --- a/examples/jms/clustered-static-oneway/src/main/resources/activemq/server1/broker.xml +++ /dev/null @@ -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. - --> - -<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> - - <!-- Connectors --> - <connectors> - <connector name="netty-connector">tcp://localhost:61617</connector> - <!-- connector to the server0 --> - <connector name="server2-connector">tcp://localhost:61618</connector> - </connectors> - - <!-- Acceptors --> - <acceptors> - <acceptor name="netty-acceptor">tcp://localhost:61617</acceptor> - </acceptors> - - <!-- Clustering configuration --> - <cluster-connections> - <cluster-connection name="my-cluster"> - <address>jms</address> - <connector-ref>netty-connector</connector-ref> - <retry-interval>500</retry-interval> - <use-duplicate-detection>true</use-duplicate-detection> - <message-load-balancing>STRICT</message-load-balancing> - <max-hops>2</max-hops> - <static-connectors allow-direct-connections-only="true"> - <connector-ref>server2-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/21bf4406/examples/jms/clustered-static-oneway/src/main/resources/activemq/server2/broker.xml ---------------------------------------------------------------------- diff --git a/examples/jms/clustered-static-oneway/src/main/resources/activemq/server2/broker.xml b/examples/jms/clustered-static-oneway/src/main/resources/activemq/server2/broker.xml deleted file mode 100644 index b1043f5..0000000 --- a/examples/jms/clustered-static-oneway/src/main/resources/activemq/server2/broker.xml +++ /dev/null @@ -1,74 +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. - --> - -<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> - - <!-- Connectors --> - <connectors> - <connector name="netty-connector">tcp://localhost:61618</connector> - </connectors> - - <!-- Acceptors --> - <acceptors> - <acceptor name="netty-acceptor">tcp://localhost:61618</acceptor> - </acceptors> - - <!-- Clustering configuration --> - <cluster-connections> - <cluster-connection name="my-cluster"> - <address>jms</address> - <connector-ref>netty-connector</connector-ref> - <retry-interval>500</retry-interval> - <use-duplicate-detection>true</use-duplicate-detection> - <message-load-balancing>STRICT</message-load-balancing> - <max-hops>2</max-hops> - </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/21bf4406/examples/jms/clustered-topic/pom.xml ---------------------------------------------------------------------- diff --git a/examples/jms/clustered-topic/pom.xml b/examples/jms/clustered-topic/pom.xml deleted file mode 100644 index 2982b21..0000000 --- a/examples/jms/clustered-topic/pom.xml +++ /dev/null @@ -1,162 +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.jms</groupId> - <artifactId>jms-examples</artifactId> - <version>1.0.1-SNAPSHOT</version> - </parent> - - <artifactId>clustered-topic</artifactId> - <packaging>jar</packaging> - <name>ActiveMQ Artemis JMS Clustered Topic Example</name> - - <properties> - <activemq.basedir>${project.basedir}/../../..</activemq.basedir> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-jms-client</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - - <profiles> - <profile> - <!-- specify -PnoServer if you don't want to start the server --> - <id>noServer</id> - <properties> - <noServer>true</noServer> - </properties> - </profile> - </profiles> - <build> - <plugins> - <plugin> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-maven-plugin</artifactId> - <executions> - <execution> - <id>create0</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <instance>${basedir}/target/server0</instance> - <configuration>${basedir}/target/classes/activemq/server0</configuration> - </configuration> - </execution> - <execution> - <id>create1</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <instance>${basedir}/target/server1</instance> - <configuration>${basedir}/target/classes/activemq/server1</configuration> - </configuration> - </execution> - <execution> - <id>start0</id> - <goals> - <goal>cli</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <spawn>true</spawn> - <location>${basedir}/target/server0</location> - <testURI>tcp://localhost:61616</testURI> - <args> - <param>run</param> - </args> - <name>server0</name> - </configuration> - </execution> - <execution> - <id>start1</id> - <goals> - <goal>cli</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <spawn>true</spawn> - <location>${basedir}/target/server1</location> - <testURI>tcp://localhost:61617</testURI> - <args> - <param>run</param> - </args> - <name>server1</name> - </configuration> - </execution> - <execution> - <id>runClient</id> - <goals> - <goal>runClient</goal> - </goals> - <configuration> - <clientClass>org.apache.activemq.artemis.jms.example.ClusteredTopicExample</clientClass> - </configuration> - </execution> - <execution> - <id>stop0</id> - <goals> - <goal>cli</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <location>${basedir}/target/server0</location> - <args> - <param>stop</param> - </args> - </configuration> - </execution> - <execution> - <id>stop1</id> - <goals> - <goal>cli</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <location>${basedir}/target/server1</location> - <args> - <param>stop</param> - </args> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.apache.activemq.examples.jms</groupId> - <artifactId>clustered-topic</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - </plugin> - </plugins> - </build> -</project> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/clustered-topic/readme.html ---------------------------------------------------------------------- diff --git a/examples/jms/clustered-topic/readme.html b/examples/jms/clustered-topic/readme.html deleted file mode 100644 index cd29bb4..0000000 --- a/examples/jms/clustered-topic/readme.html +++ /dev/null @@ -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 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><cluster-connection name="my-cluster"> - <address>jms</address> - <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> - </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> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/clustered-topic/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredTopicExample.java ---------------------------------------------------------------------- diff --git a/examples/jms/clustered-topic/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredTopicExample.java b/examples/jms/clustered-topic/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredTopicExample.java deleted file mode 100644 index f3ce9a0..0000000 --- a/examples/jms/clustered-topic/src/main/java/org/apache/activemq/artemis/jms/example/ClusteredTopicExample.java +++ /dev/null @@ -1,129 +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 javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.jms.Topic; -import javax.naming.InitialContext; - -import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; -import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; - -/** - * A simple example that shows a JMS Topic clustered across two nodes of a cluster. - * Messages are sent on one node and received by consumers on both nodes. - */ -public class ClusteredTopicExample { - - public static void main(final String[] args) throws Exception { - Connection connection0 = null; - - Connection connection1 = null; - - InitialContext ic0 = null; - - InitialContext ic1 = null; - - try { - - // Step 1. Instantiate topic - Topic topic = ActiveMQJMSClient.createTopic("exampleTopic"); - - // Step 2. Look-up a JMS Connection Factory object from JNDI on server 0 - ConnectionFactory cf0 = new ActiveMQConnectionFactory("tcp://localhost:61616"); - - // Step 3. Look-up a JMS Connection Factory object from JNDI on server 1 - ConnectionFactory cf1 = new ActiveMQConnectionFactory("tcp://localhost:61617"); - - // Step 4. We create a JMS Connection connection0 which is a connection to server 0 - connection0 = cf0.createConnection(); - - // Step 5. We create a JMS Connection connection1 which is a connection to server 1 - connection1 = cf1.createConnection(); - - // Step 6. We create a JMS Session on server 0 - Session session0 = connection0.createSession(false, Session.AUTO_ACKNOWLEDGE); - - // Step 7. We create a JMS Session on server 1 - Session session1 = connection1.createSession(false, Session.AUTO_ACKNOWLEDGE); - - // Step 8. We start the connections to ensure delivery occurs on them - connection0.start(); - - connection1.start(); - - // Step 9. We create JMS MessageConsumer objects on server 0 and server 1 - MessageConsumer consumer0 = session0.createConsumer(topic); - - MessageConsumer consumer1 = session1.createConsumer(topic); - - Thread.sleep(1000); - - // Step 10. We create a JMS MessageProducer object on server 0 - MessageProducer producer = session0.createProducer(topic); - - // Step 11. We send some messages to server 0 - - final int numMessages = 10; - - for (int i = 0; i < numMessages; i++) { - TextMessage message = session0.createTextMessage("This is text message " + i); - - producer.send(message); - - System.out.println("Sent message: " + message.getText()); - } - - // Step 12. We now consume those messages on *both* server 0 and server 1. - // We note that all messages have been consumed by *both* consumers. - // JMS Topics implement *publish-subscribe* messaging where all consumers get a copy of all messages - - for (int i = 0; i < numMessages; i++) { - TextMessage message0 = (TextMessage) consumer0.receive(5000); - - System.out.println("Got message: " + message0.getText() + " from node 0"); - - TextMessage message1 = (TextMessage) consumer1.receive(5000); - - System.out.println("Got message: " + message1.getText() + " from node 1"); - } - } - finally { - // Step 15. Be sure to close our JMS resources! - if (connection0 != null) { - connection0.close(); - } - - if (connection1 != null) { - connection1.close(); - } - - if (ic0 != null) { - ic0.close(); - } - - if (ic1 != null) { - ic1.close(); - } - } - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/clustered-topic/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/jms/clustered-topic/src/main/resources/activemq/server0/broker.xml b/examples/jms/clustered-topic/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index a4e8dde..0000000 --- a/examples/jms/clustered-topic/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,97 +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 topic used by the example--> - <topic name="exampleTopic"/> - </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> - - <!-- Connectors --> - - <connectors> - <connector name="netty-connector">tcp://localhost:61616</connector> - </connectors> - - <!-- Acceptors --> - <acceptors> - <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor> - </acceptors> - - <!-- Clustering configuration --> - - <broadcast-groups> - <broadcast-group name="my-broadcast-group"> - <group-address>${udp-address:231.7.7.7}</group-address> - <group-port>9876</group-port> - <broadcast-period>100</broadcast-period> - <connector-ref>netty-connector</connector-ref> - </broadcast-group> - </broadcast-groups> - - <discovery-groups> - <discovery-group name="my-discovery-group"> - <group-address>${udp-address:231.7.7.7}</group-address> - <group-port>9876</group-port> - <refresh-timeout>10000</refresh-timeout> - </discovery-group> - </discovery-groups> - - <cluster-connections> - <cluster-connection name="my-cluster"> - <address>jms</address> - <connector-ref>netty-connector</connector-ref> - <retry-interval>500</retry-interval> - <use-duplicate-detection>true</use-duplicate-detection> - <message-load-balancing>STRICT</message-load-balancing> - <max-hops>1</max-hops> - <discovery-group-ref discovery-group-name="my-discovery-group"/> - </cluster-connection> - </cluster-connections> - - <!-- other configuration --> - - <security-settings> - <!--security for example queue--> - <security-setting match="jms.topic.exampleTopic"> - <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/21bf4406/examples/jms/clustered-topic/src/main/resources/activemq/server1/broker.xml ---------------------------------------------------------------------- diff --git a/examples/jms/clustered-topic/src/main/resources/activemq/server1/broker.xml b/examples/jms/clustered-topic/src/main/resources/activemq/server1/broker.xml deleted file mode 100644 index 78beec3..0000000 --- a/examples/jms/clustered-topic/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 topic used by the example--> - <topic name="exampleTopic"/> - </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> - - <!-- Connectors --> - <connectors> - <connector name="netty-connector">tcp://localhost:61617</connector> - </connectors> - - <!-- Acceptors --> - <acceptors> - <acceptor name="netty-acceptor">tcp://localhost:61617</acceptor> - </acceptors> - - <!-- Clustering configuration --> - <broadcast-groups> - <broadcast-group name="my-broadcast-group"> - <group-address>${udp-address:231.7.7.7}</group-address> - <group-port>9876</group-port> - <broadcast-period>100</broadcast-period> - <connector-ref>netty-connector</connector-ref> - </broadcast-group> - </broadcast-groups> - - <discovery-groups> - <discovery-group name="my-discovery-group"> - <group-address>${udp-address:231.7.7.7}</group-address> - <group-port>9876</group-port> - <refresh-timeout>10000</refresh-timeout> - </discovery-group> - </discovery-groups> - - <cluster-connections> - <cluster-connection name="my-cluster"> - <address>jms</address> - <connector-ref>netty-connector</connector-ref> - <retry-interval>500</retry-interval> - <use-duplicate-detection>true</use-duplicate-detection> - <message-load-balancing>STRICT</message-load-balancing> - <max-hops>1</max-hops> - <discovery-group-ref discovery-group-name="my-discovery-group"/> - </cluster-connection> - </cluster-connections> - - <!-- other configuration --> - - <security-settings> - <!--security for example queue--> - <security-setting match="jms.topic.exampleTopic"> - <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/21bf4406/examples/jms/colocated-failover-scale-down/pom.xml ---------------------------------------------------------------------- diff --git a/examples/jms/colocated-failover-scale-down/pom.xml b/examples/jms/colocated-failover-scale-down/pom.xml deleted file mode 100644 index d2947c4..0000000 --- a/examples/jms/colocated-failover-scale-down/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.jms</groupId> - <artifactId>jms-examples</artifactId> - <version>1.0.1-SNAPSHOT</version> - </parent> - - <artifactId>colocated-failover-scale-down</artifactId> - <packaging>jar</packaging> - <name>ActiveMQ Artemis JMS Colocated Failover Recover Only 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> - </configuration> - </execution> - <execution> - <id>create1</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <instance>${basedir}/target/server1</instance> - <configuration>${basedir}/target/classes/activemq/server1</configuration> - </configuration> - </execution> - <execution> - <id>runClient</id> - <goals> - <goal>runClient</goal> - </goals> - <configuration> - <clientClass>org.apache.activemq.artemis.jms.example.ColocatedFailoverScaleDownExample - </clientClass> - <args> - <param>${basedir}/target/server0</param> - <param>${basedir}/target/server1</param> - </args> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.apache.activemq.examples.jms</groupId> - <artifactId>colocated-failover-scale-down</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - </plugin> - </plugins> - </build> - -</project> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/colocated-failover-scale-down/readme.html ---------------------------------------------------------------------- diff --git a/examples/jms/colocated-failover-scale-down/readme.html b/examples/jms/colocated-failover-scale-down/readme.html deleted file mode 100644 index ffcd73b..0000000 --- a/examples/jms/colocated-failover-scale-down/readme.html +++ /dev/null @@ -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><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><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> - </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> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/colocated-failover-scale-down/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverScaleDownExample.java ---------------------------------------------------------------------- diff --git a/examples/jms/colocated-failover-scale-down/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverScaleDownExample.java b/examples/jms/colocated-failover-scale-down/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverScaleDownExample.java deleted file mode 100644 index 69b7b12..0000000 --- a/examples/jms/colocated-failover-scale-down/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverScaleDownExample.java +++ /dev/null @@ -1,141 +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.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.naming.InitialContext; -import java.lang.IllegalStateException; -import java.util.Hashtable; - -/** - * A simple example that demonstrates server side load-balancing of messages between the queue instances on different - * nodes of the cluster. - */ -public class ColocatedFailoverScaleDownExample { - - private static Process server0; - - private static Process server1; - - public static void main(final String[] args) throws Exception { - final int numMessages = 30; - - Connection connection = null; - Connection connection1 = null; - - InitialContext initialContext = null; - InitialContext initialContext1 = null; - - try { - server0 = ServerUtil.startServer(args[0], ColocatedFailoverScaleDownExample.class.getSimpleName() + "0", 0, 5000); - server1 = ServerUtil.startServer(args[1], ColocatedFailoverScaleDownExample.class.getSimpleName() + "1", 1, 5000); - - // Step 1. Get an initial context for looking up JNDI for both servers - Hashtable<String, Object> properties = new Hashtable<String, Object>(); - properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); - properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61617"); - initialContext1 = new InitialContext(properties); - - properties = new Hashtable<String, Object>(); - properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); - properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61616?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1"); - properties.put("queue.queue/exampleQueue", "exampleQueue"); - initialContext = new InitialContext(properties); - - // Step 2. Look up the JMS resources from JNDI - Queue queue = (Queue) initialContext.lookup("queue/exampleQueue"); - ConnectionFactory connectionFactory = (ConnectionFactory) initialContext.lookup("ConnectionFactory"); - ConnectionFactory connectionFactory1 = (ConnectionFactory) initialContext1.lookup("ConnectionFactory"); - - // Step 3. Create a JMS Connections - connection = connectionFactory.createConnection(); - connection1 = connectionFactory1.createConnection(); - - // Step 4. Create a *non-transacted* JMS Session with client acknowledgement - Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); - Session session1 = connection1.createSession(false, Session.CLIENT_ACKNOWLEDGE); - - // Step 5. Create a JMS MessageProducers - MessageProducer producer = session.createProducer(queue); - MessageProducer producer1 = session1.createProducer(queue); - - // Step 6. Send some messages to both servers - 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()); - message = session1.createTextMessage("This is another text message " + i); - producer1.send(message); - System.out.println("Sent message: " + message.getText()); - } - - // Step 7. Crash server #0, the live server, and wait a little while to make sure - // it has really crashed - ServerUtil.killServer(server0); - System.out.println("Waiting for scale-down to complete..."); - Thread.sleep(10000); - - // Step 8. start the connection ready to receive messages - connection1.start(); - - // Step 9.create a consumer - MessageConsumer consumer = session1.createConsumer(queue); - - // Step 10. Receive and acknowledge all of the sent messages, notice that they will be out of order, this is - // because they were initially round robined to both nodes then when the server failed were reloaded into the - // live server. - TextMessage message0 = null; - for (int i = 0; i < numMessages * 2; i++) { - message0 = (TextMessage) consumer.receive(5000); - if (message0 == null) { - throw new IllegalStateException("Message not received!"); - } - System.out.println("Got message: " + message0.getText()); - } - message0.acknowledge(); - } - finally { - // Step 11. Be sure to close our resources! - - if (connection != null) { - connection.close(); - } - - if (initialContext != null) { - initialContext.close(); - } - if (connection1 != null) { - connection1.close(); - } - - if (initialContext1 != null) { - initialContext1.close(); - } - - ServerUtil.killServer(server0); - ServerUtil.killServer(server1); - } - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server0/broker.xml b/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 60201ca..0000000 --- a/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,129 +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.dir:../data}/bindings</bindings-directory> - - <journal-directory>${data.dir:../data}/journal</journal-directory> - - <large-messages-directory>${data.dir:../data}/largemessages</large-messages-directory> - - <paging-directory>${data.dir:../data}/paging</paging-directory> - <!-- Connectors --> - - <connectors> - <connector name="invm-connector">vm://0</connector> - <connector name="netty-connector">tcp://localhost:61616</connector> - </connectors> - - <!-- Acceptors --> - <acceptors> - <acceptor name="invm-acceptor">vm://0</acceptor> - <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor> - </acceptors> - - <!-- Clustering configuration --> - <broadcast-groups> - <broadcast-group name="my-broadcast-group"> - <group-address>${udp-address:231.7.7.7}</group-address> - <group-port>9876</group-port> - <broadcast-period>100</broadcast-period> - <connector-ref>netty-connector</connector-ref> - </broadcast-group> - </broadcast-groups> - - <discovery-groups> - <discovery-group name="my-discovery-group"> - <group-address>${udp-address:231.7.7.7}</group-address> - <group-port>9876</group-port> - <refresh-timeout>10000</refresh-timeout> - </discovery-group> - </discovery-groups> - - <cluster-connections> - <cluster-connection name="my-cluster"> - <address>jms</address> - <connector-ref>netty-connector</connector-ref> - <retry-interval>500</retry-interval> - <!-- since the backup servers scale down we need a sensible setting here so the bridge will stop --> - <reconnect-attempts>5</reconnect-attempts> - <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> - - <!-- a colocated server that will allow shared store backups to be requested, the default for this template is to scale down--> - <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> - <failover-on-shutdown>true</failover-on-shutdown> - </master> - <slave> - <scale-down/> - </slave> - </colocated> - </shared-store> - </ha-policy> - - <!-- 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-setting match="jms.queue.activemq.management.#"> - <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-setting match="jms.queue.activemq.management"> - <permission type="manage" roles="guest"/> - </security-setting> - </security-settings> - - </core> -</configuration> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server1/broker.xml ---------------------------------------------------------------------- diff --git a/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server1/broker.xml b/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server1/broker.xml deleted file mode 100644 index 7892fc1..0000000 --- a/examples/jms/colocated-failover-scale-down/src/main/resources/activemq/server1/broker.xml +++ /dev/null @@ -1,127 +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.dir:../data}/bindings</bindings-directory> - - <journal-directory>${data.dir:../data}/journal</journal-directory> - - <large-messages-directory>${data.dir:../data}/largemessages</large-messages-directory> - - <paging-directory>${data.dir:../data}/paging</paging-directory> - - <!-- Connectors --> - <connectors> - <connector name="invm-connector">vm://0</connector> - <connector name="netty-connector">tcp://localhost:61617</connector> - </connectors> - - <!-- Acceptors --> - <acceptors> - <acceptor name="invm-acceptor">vm://0</acceptor> - <acceptor name="netty-acceptor">tcp://localhost:61617</acceptor> - </acceptors> - - <!-- Clustering configuration --> - <broadcast-groups> - <broadcast-group name="my-broadcast-group"> - <group-address>${udp-address:231.7.7.7}</group-address> - <group-port>9876</group-port> - <broadcast-period>100</broadcast-period> - <connector-ref>netty-connector</connector-ref> - </broadcast-group> - </broadcast-groups> - - <discovery-groups> - <discovery-group name="my-discovery-group"> - <group-address>${udp-address:231.7.7.7}</group-address> - <group-port>9876</group-port> - <refresh-timeout>10000</refresh-timeout> - </discovery-group> - </discovery-groups> - - <cluster-connections> - <cluster-connection name="my-cluster"> - <address>jms</address> - <connector-ref>netty-connector</connector-ref> - <retry-interval>500</retry-interval> - <!-- since the backup servers scale down we need a sensible setting here so the bridge will stop --> - <reconnect-attempts>5</reconnect-attempts> - <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> - - <!-- a colocated server that will allow shared store backups to be requested, the default for this template is to scale down--> - <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> - - <!-- 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-setting match="jms.queue.activemq.management.#"> - <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-setting match="jms.queue.activemq.management"> - <permission type="manage" roles="guest"/> - </security-setting> - </security-settings> - - </core> -</configuration> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/colocated-failover/pom.xml ---------------------------------------------------------------------- diff --git a/examples/jms/colocated-failover/pom.xml b/examples/jms/colocated-failover/pom.xml deleted file mode 100644 index 121b296..0000000 --- a/examples/jms/colocated-failover/pom.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. ---> - -<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.jms</groupId> - <artifactId>jms-examples</artifactId> - <version>1.0.1-SNAPSHOT</version> - </parent> - - <artifactId>colocated-failover</artifactId> - <packaging>jar</packaging> - <name>ActiveMQ Artemis JMS Colocated 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> - </configuration> - </execution> - <execution> - <id>create1</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <instance>${basedir}/target/server1</instance> - <configuration>${basedir}/target/classes/activemq/server1</configuration> - </configuration> - </execution> - <execution> - <id>runClient</id> - <goals> - <goal>runClient</goal> - </goals> - <configuration> - <clientClass>org.apache.activemq.artemis.jms.example.ColocatedFailoverExample</clientClass> - <args> - <param>${basedir}/target/server0</param> - <param>${basedir}/target/server1</param> - </args> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.apache.activemq.examples.jms</groupId> - <artifactId>colocated-failover</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - </plugin> - </plugins> - </build> -</project> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/colocated-failover/readme.html ---------------------------------------------------------------------- diff --git a/examples/jms/colocated-failover/readme.html b/examples/jms/colocated-failover/readme.html deleted file mode 100644 index dceae4f..0000000 --- a/examples/jms/colocated-failover/readme.html +++ /dev/null @@ -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><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> - </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> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/colocated-failover/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverExample.java ---------------------------------------------------------------------- diff --git a/examples/jms/colocated-failover/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverExample.java b/examples/jms/colocated-failover/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverExample.java deleted file mode 100644 index 2d96738..0000000 --- a/examples/jms/colocated-failover/src/main/java/org/apache/activemq/artemis/jms/example/ColocatedFailoverExample.java +++ /dev/null @@ -1,148 +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.MessageConsumer; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.naming.InitialContext; -import java.lang.IllegalStateException; -import java.util.Hashtable; - -/** - * A simple example that demonstrates a colocated server - */ -public class ColocatedFailoverExample { - - private static Process server0; - - private static Process server1; - - public static void main(final String[] args) throws Exception { - final int numMessages = 30; - - Connection connection = null; - Connection connection1 = null; - - InitialContext initialContext = null; - InitialContext initialContext1 = null; - - try { - server0 = ServerUtil.startServer(args[0], ColocatedFailoverExample.class.getSimpleName() + "0", 0, 5000); - server1 = ServerUtil.startServer(args[1], ColocatedFailoverExample.class.getSimpleName() + "1", 1, 5000); - - // Step 1. Get an initial context for looking up JNDI for both servers - Hashtable<String, Object> properties = new Hashtable<String, Object>(); - properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); - properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61616?ha=true&retryInterval=1000&retryIntervalMultiplier=1.0&reconnectAttempts=-1"); - properties.put("queue.queue/exampleQueue", "exampleQueue"); - initialContext = new InitialContext(properties); - - properties = new Hashtable<String, Object>(); - properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory"); - properties.put("connectionFactory.ConnectionFactory", "tcp://localhost:61617"); - initialContext1 = new InitialContext(properties); - - // Step 2. Look up the JMS resources from JNDI - Queue queue = (Queue) initialContext.lookup("queue/exampleQueue"); - ConnectionFactory connectionFactory = (ConnectionFactory) initialContext.lookup("ConnectionFactory"); - ConnectionFactory connectionFactory1 = (ConnectionFactory) initialContext1.lookup("ConnectionFactory"); - - // Step 3. Create a JMS Connections - connection = connectionFactory.createConnection(); - connection1 = connectionFactory1.createConnection(); - - // Step 4. Create a *non-transacted* JMS Session with client acknowledgement - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - Session session1 = connection1.createSession(false, Session.AUTO_ACKNOWLEDGE); - - // Step 5. Create a JMS MessageProducers - MessageProducer producer = session.createProducer(queue); - MessageProducer producer1 = session1.createProducer(queue); - - // Step 6. Send some messages to both servers - 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()); - message = session1.createTextMessage("This is another text message " + i); - producer1.send(message); - System.out.println("Sent message: " + message.getText()); - } - - // Step 7. Crash server #0, the live server, and wait a little while to make sure - // it has really crashed - ServerUtil.killServer(server0); - Thread.sleep(10000); - - // Step 8. start the connection ready to receive messages - connection.start(); - connection1.start(); - - // Step 9.create a consumer - MessageConsumer consumer = session1.createConsumer(queue); - - // Step 10. Receive and acknowledge all of the sent messages, the backup server that is colocated with server 1 - // will have become live and is now handling messages for server 0. - TextMessage message0 = null; - for (int i = 0; i < numMessages; i++) { - message0 = (TextMessage) consumer.receive(5000); - if (message0 == null) { - throw new IllegalStateException("Message not received!"); - } - System.out.println("Got message: " + message0.getText()); - } - message0.acknowledge(); - - MessageConsumer consumer1 = session.createConsumer(queue); - - // Step 11. Receive and acknowledge the rest of the sent messages from server 1. - for (int i = 0; i < numMessages; i++) { - message0 = (TextMessage) consumer1.receive(5000); - System.out.println("Got message: " + message0.getText()); - } - message0.acknowledge(); - } - finally { - // Step 11. Be sure to close our resources! - - if (connection != null) { - connection.close(); - } - - if (initialContext != null) { - initialContext.close(); - } - if (connection1 != null) { - connection1.close(); - } - - if (initialContext1 != null) { - initialContext1.close(); - } - - ServerUtil.killServer(server0); - ServerUtil.killServer(server1); - } - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/colocated-failover/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/jms/colocated-failover/src/main/resources/activemq/server0/broker.xml b/examples/jms/colocated-failover/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 0a4103f..0000000 --- a/examples/jms/colocated-failover/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,115 +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.dir:../data}/bindings</bindings-directory> - - <journal-directory>${data.dir:../data}/journal</journal-directory> - - <large-messages-directory>${data.dir:../data}/largemessages</large-messages-directory> - - <paging-directory>${data.dir:../data}/paging</paging-directory> - <!-- Connectors --> - - <connectors> - <connector name="netty-connector">tcp://localhost:61616</connector> - </connectors> - - <!-- Acceptors --> - <acceptors> - <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor> - </acceptors> - - <!-- Clustering configuration --> - <broadcast-groups> - <broadcast-group name="my-broadcast-group"> - <group-address>${udp-address:231.7.7.7}</group-address> - <group-port>9876</group-port> - <broadcast-period>100</broadcast-period> - <connector-ref>netty-connector</connector-ref> - </broadcast-group> - </broadcast-groups> - - <discovery-groups> - <discovery-group name="my-discovery-group"> - <group-address>${udp-address:231.7.7.7}</group-address> - <group-port>9876</group-port> - <refresh-timeout>10000</refresh-timeout> - </discovery-group> - </discovery-groups> - - <cluster-connections> - <cluster-connection name="my-cluster"> - <address>jms</address> - <connector-ref>netty-connector</connector-ref> - <retry-interval>500</retry-interval> - <use-duplicate-detection>true</use-duplicate-detection> - <message-load-balancing>STRICT</message-load-balancing> - <max-hops>1</max-hops> - <discovery-group-ref discovery-group-name="my-discovery-group"/> - </cluster-connection> - </cluster-connections> - - <!-- a colocated server that will allow shared store full backups to be requested--> - <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> - <failover-on-shutdown>true</failover-on-shutdown> - </master> - <slave> - <failover-on-shutdown>true</failover-on-shutdown> - </slave> - </colocated> - </shared-store> - </ha-policy> - - <!-- 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/21bf4406/examples/jms/colocated-failover/src/main/resources/activemq/server1/broker.xml ---------------------------------------------------------------------- diff --git a/examples/jms/colocated-failover/src/main/resources/activemq/server1/broker.xml b/examples/jms/colocated-failover/src/main/resources/activemq/server1/broker.xml deleted file mode 100644 index 8083f27..0000000 --- a/examples/jms/colocated-failover/src/main/resources/activemq/server1/broker.xml +++ /dev/null @@ -1,114 +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.dir:../data}/bindings</bindings-directory> - - <journal-directory>${data.dir:../data}/journal</journal-directory> - - <large-messages-directory>${data.dir:../data}/largemessages</large-messages-directory> - - <paging-directory>${data.dir:../data}/paging</paging-directory> - - <!-- Connectors --> - <connectors> - <connector name="netty-connector">tcp://localhost:61617</connector> - </connectors> - - <!-- Acceptors --> - <acceptors> - <acceptor name="netty-acceptor">tcp://localhost:61617</acceptor> - </acceptors> - - <!-- Clustering configuration --> - <broadcast-groups> - <broadcast-group name="my-broadcast-group"> - <group-address>${udp-address:231.7.7.7}</group-address> - <group-port>9876</group-port> - <broadcast-period>100</broadcast-period> - <connector-ref>netty-connector</connector-ref> - </broadcast-group> - </broadcast-groups> - - <discovery-groups> - <discovery-group name="my-discovery-group"> - <group-address>${udp-address:231.7.7.7}</group-address> - <group-port>9876</group-port> - <refresh-timeout>10000</refresh-timeout> - </discovery-group> - </discovery-groups> - - <cluster-connections> - <cluster-connection name="my-cluster"> - <address>jms</address> - <connector-ref>netty-connector</connector-ref> - <retry-interval>500</retry-interval> - <use-duplicate-detection>true</use-duplicate-detection> - <message-load-balancing>STRICT</message-load-balancing> - <max-hops>1</max-hops> - <discovery-group-ref discovery-group-name="my-discovery-group"/> - </cluster-connection> - </cluster-connections> - - <!-- a colocated server that will allow shared store full backups to be requested--> - <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> - <failover-on-shutdown>true</failover-on-shutdown> - </master> - <slave> - <failover-on-shutdown>true</failover-on-shutdown> - </slave> - </colocated> - </shared-store> - </ha-policy> - - <!-- 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/21bf4406/examples/jms/common/common.css ---------------------------------------------------------------------- diff --git a/examples/jms/common/common.css b/examples/jms/common/common.css deleted file mode 100644 index 4903b2a..0000000 --- a/examples/jms/common/common.css +++ /dev/null @@ -1,47 +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. - */ - -body { -} - -h1 { - margin-top: 110px; - font-size: 250%; -} - -code { - background-color: lightgrey; - color:#333; -} - -pre { - background-color: lightgrey; - display:block; - overflow:auto; - border: dotted grey 1px; -} - -abbr { - border-bottom: 1px dotted #333; cursor: help; -} - -.missing-doc { - background-color: red; - border: dotted black 1px; -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/common/config/logging.properties ---------------------------------------------------------------------- diff --git a/examples/jms/common/config/logging.properties b/examples/jms/common/config/logging.properties deleted file mode 100644 index 4f4a9de..0000000 --- a/examples/jms/common/config/logging.properties +++ /dev/null @@ -1,52 +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. - -############################################################ -# Default Logging Configuration File -# -# You can use a different file by specifying a filename -# with the java.util.logging.config.file system property. -# For example java -Djava.util.logging.config.file=myfile -############################################################ - -############################################################ -# Global properties -############################################################ - -# "handlers" specifies a comma separated list of log Handler -# classes. These handlers will be installed during VM startup. -# Note that these classes must be on the system classpath. -# By default we only configure a ConsoleHandler, which will only -# show messages at the INFO and above levels. -handlers=java.util.logging.ConsoleHandler -#handlers=java.util.logging.ConsoleHandler,java.util.logging.FileHandler -java.util.logging.ConsoleHandler.formatter=org.apache.activemq.artemis.integration.logging.ActiveMQLoggerFormatter -java.util.logging.FileHandler.level=INFO -java.util.logging.FileHandler.formatter=org.apache.activemq.artemis.integration.logging.ActiveMQLoggerFormatter -java.util.logging.FileHandler.pattern=logs/activemq.log -# Default global logging level. -# This specifies which kinds of events are logged across -# all loggers. For any given facility this global level -# can be overridden by a facility specific level -# Note that the ConsoleHandler also has a separate level -# setting to limit messages printed to the console. -.level= INFO - -############################################################ -# Handler specific properties. -# Describes specific configuration info for Handlers. -############################################################ http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/common/config/server.properties ---------------------------------------------------------------------- diff --git a/examples/jms/common/config/server.properties b/examples/jms/common/config/server.properties deleted file mode 100644 index cff66e2..0000000 --- a/examples/jms/common/config/server.properties +++ /dev/null @@ -1,18 +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. - -server.args=-XX:+UseParallelGC -Xms256M -Xmx256M -XX:+AggressiveOpts -XX:+UseFastAccessorMethods -Dcom.sun.management.jmxremote -Djava.util.logging.config.file=${imported.basedir}/config/logging.properties -Djava.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory
