http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/topic-hierarchies/pom.xml ---------------------------------------------------------------------- diff --git a/examples/jms/topic-hierarchies/pom.xml b/examples/jms/topic-hierarchies/pom.xml deleted file mode 100644 index 320e870..0000000 --- a/examples/jms/topic-hierarchies/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.jms</groupId> - <artifactId>jms-examples</artifactId> - <version>1.0.1-SNAPSHOT</version> - </parent> - - <artifactId>topic-hierarchies</artifactId> - <packaging>jar</packaging> - <name>ActiveMQ Artemis JMS Topic Hierarchies 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>create</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - </configuration> - </execution> - <execution> - <id>start</id> - <goals> - <goal>cli</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <spawn>true</spawn> - <testURI>tcp://localhost:61616</testURI> - <args> - <param>run</param> - </args> - </configuration> - </execution> - <execution> - <id>runClient</id> - <goals> - <goal>runClient</goal> - </goals> - <configuration> - <clientClass>org.apache.activemq.artemis.jms.example.TopicHierarchyExample</clientClass> - </configuration> - </execution> - <execution> - <id>stop</id> - <goals> - <goal>cli</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <args> - <param>stop</param> - </args> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.apache.activemq.examples.jms</groupId> - <artifactId>topic-hierarchies</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/topic-hierarchies/readme.html ---------------------------------------------------------------------- diff --git a/examples/jms/topic-hierarchies/readme.html b/examples/jms/topic-hierarchies/readme.html deleted file mode 100644 index c901d57..0000000 --- a/examples/jms/topic-hierarchies/readme.html +++ /dev/null @@ -1,42 +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 Topic Hierarchy 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>Topic Hierarchy 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>ActiveMQ Artemis supports topic hierarchies. With a topic hierarchy you can register a subscriber with a wild-card - and that subscriber will receive any messages routed to an address that match the wildcard.</p> - <p>ActiveMQ Artemis wild-cards can use the character '#' which means "match any number of words", and - the character '*' which means "match a single word". Words are delimited by the character "."</p> - <p>For example if I subscribe using the wild-card "news.europe.#", then that would match messages sent to the addresses - "news.europe", "news.europe.sport" and "news.europe.entertainment", but it does not match messages sent to the - address "news.usa.wrestling"</p> - <p>For more information on the wild-card syntax please consult the user manual.</p> - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/topic-hierarchies/src/main/java/org/apache/activemq/artemis/jms/example/TopicHierarchyExample.java ---------------------------------------------------------------------- diff --git a/examples/jms/topic-hierarchies/src/main/java/org/apache/activemq/artemis/jms/example/TopicHierarchyExample.java b/examples/jms/topic-hierarchies/src/main/java/org/apache/activemq/artemis/jms/example/TopicHierarchyExample.java deleted file mode 100644 index 0a720da..0000000 --- a/examples/jms/topic-hierarchies/src/main/java/org/apache/activemq/artemis/jms/example/TopicHierarchyExample.java +++ /dev/null @@ -1,121 +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.Message; -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; - -/** - * This example demonstrates how a JMS TopicSubscriber can be created to subscribe to a wild-card Topic. - * - * For more information please see the readme.html - */ -public class TopicHierarchyExample { - - public static void main(final String[] args) throws Exception { - Connection connection = null; - InitialContext initialContext = null; - try { - // Step 1. Create an initial context to perform the JNDI lookup. - initialContext = new InitialContext(); - - // Step 3. Perform a lookup on the Connection Factory - ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("ConnectionFactory"); - - // Step 4. Create a JMS Connection - connection = cf.createConnection(); - - // Step 5. Create a JMS Session - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - - // Step 6. Instantiate a topic representing the wildcard we're going to subscribe to - Topic topicSubscribe = ActiveMQJMSClient.createTopic("news.europe.#"); - - // Step 7. Create a consumer (topic subscriber) that will consume using that wildcard - // The consumer will receive any messages sent to any topic that starts with news.europe - MessageConsumer messageConsumer = session.createConsumer(topicSubscribe); - - // Step 8. Create an anonymous producer - MessageProducer producer = session.createProducer(null); - - // Step 9. Instantiate some more topic objects corresponding to the individual topics - // we're going to send messages to - Topic topicNewsUsaWrestling = ActiveMQJMSClient.createTopic("news.usa.wrestling"); - - Topic topicNewsEuropeSport = ActiveMQJMSClient.createTopic("news.europe.sport"); - - Topic topicNewsEuropeEntertainment = ActiveMQJMSClient.createTopic("news.europe.entertainment"); - - // Step 10. Send a message destined for the usa wrestling topic - TextMessage messageWrestlingNews = session.createTextMessage("Hulk Hogan starts ballet classes"); - - producer.send(topicNewsUsaWrestling, messageWrestlingNews); - - // Step 11. Send a message destined for the europe sport topic - TextMessage messageEuropeSport = session.createTextMessage("Lewis Hamilton joins European synchronized swimming team"); - - producer.send(topicNewsEuropeSport, messageEuropeSport); - - // Step 12. Send a message destined for the europe entertainment topic - TextMessage messageEuropeEntertainment = session.createTextMessage("John Lennon resurrected from dead"); - - producer.send(topicNewsEuropeEntertainment, messageEuropeEntertainment); - - // Step 9. Start the connection - - connection.start(); - - // Step 10. We don't receive the usa wrestling message since we subscribed to news.europe.# and - // that doesn't match news.usa.wrestling. However we do receive the Europe sport message, and the - // europe entertainment message, since these match the wildcard. - - TextMessage messageReceived1 = (TextMessage) messageConsumer.receive(5000); - - System.out.println("Received message: " + messageReceived1.getText()); - - TextMessage messageReceived2 = (TextMessage) messageConsumer.receive(5000); - - System.out.println("Received message: " + messageReceived2.getText()); - - Message message = messageConsumer.receive(1000); - - if (message != null) { - throw new IllegalStateException("Message was not null."); - } - - System.out.println("Didn't received any more message: " + message); - } - finally { - // Step 12. Be sure to close our resources! - if (initialContext != null) { - initialContext.close(); - } - if (connection != null) { - connection.close(); - } - } - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/topic-hierarchies/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/jms/topic-hierarchies/src/main/resources/activemq/server0/broker.xml b/examples/jms/topic-hierarchies/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 9ec66c6..0000000 --- a/examples/jms/topic-hierarchies/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,71 +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 topics used by the example--> - - <topic name="news"/> - - <topic name="news.usa"/> - - <topic name="news.usa.wrestling"/> - - <topic name="news.europe"/> - - <topic name="news.europe.sport"/> - - <topic name="news.europe.entertainment"/> - </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> - - <!-- Acceptors --> - <acceptors> - <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor> - </acceptors> - - <!-- Other config --> - - <security-settings> - <!--security for example queue--> - <security-setting match="jms.#"> - <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/topic-hierarchies/src/main/resources/jndi.properties ---------------------------------------------------------------------- diff --git a/examples/jms/topic-hierarchies/src/main/resources/jndi.properties b/examples/jms/topic-hierarchies/src/main/resources/jndi.properties deleted file mode 100644 index 5cbe72c..0000000 --- a/examples/jms/topic-hierarchies/src/main/resources/jndi.properties +++ /dev/null @@ -1,19 +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 http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/topic-selector-example1/pom.xml ---------------------------------------------------------------------- diff --git a/examples/jms/topic-selector-example1/pom.xml b/examples/jms/topic-selector-example1/pom.xml deleted file mode 100644 index 01c528a..0000000 --- a/examples/jms/topic-selector-example1/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.jms</groupId> - <artifactId>jms-examples</artifactId> - <version>1.0.1-SNAPSHOT</version> - </parent> - - <artifactId>topic-selector1</artifactId> - <packaging>jar</packaging> - <name>ActiveMQ Artemis JMS Topic Selector Example 1</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>create</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - </configuration> - </execution> - <execution> - <id>start</id> - <goals> - <goal>cli</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <spawn>true</spawn> - <testURI>tcp://localhost:61616</testURI> - <args> - <param>run</param> - </args> - </configuration> - </execution> - <execution> - <id>runClient</id> - <goals> - <goal>runClient</goal> - </goals> - <configuration> - <clientClass>org.apache.activemq.artemis.jms.example.TopicSelectorExample1</clientClass> - </configuration> - </execution> - <execution> - <id>stop</id> - <goals> - <goal>cli</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <args> - <param>stop</param> - </args> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.apache.activemq.examples.jms</groupId> - <artifactId>topic-selector1</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/topic-selector-example1/readme.html ---------------------------------------------------------------------- diff --git a/examples/jms/topic-selector-example1/readme.html b/examples/jms/topic-selector-example1/readme.html deleted file mode 100644 index 5681852..0000000 --- a/examples/jms/topic-selector-example1/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 Topic Selector Example 1</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 Topic Selector Example 1</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 shows how messages can be consumed from a topic using Message Selectors.</p> - <p>Consumers (or Subscribers) will only consume messages routed to a topic that match the provided selector</p> - <p>Topics and selectors are a standard part of JMS, please consult the JMS 1.1 specification for full details.</p> - - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/topic-selector-example1/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample1.java ---------------------------------------------------------------------- diff --git a/examples/jms/topic-selector-example1/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample1.java b/examples/jms/topic-selector-example1/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample1.java deleted file mode 100644 index 53aee12..0000000 --- a/examples/jms/topic-selector-example1/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample1.java +++ /dev/null @@ -1,145 +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; - -/** - * A simple JMS Topic example that creates a producer and consumer on a queue and sends and receives a message. - */ -public class TopicSelectorExample1 { - - public static void main(final String[] args) throws Exception { - Connection connection = null; - - InitialContext initialContext = null; - try { - - // Step 1. Create an initial context to perform the JNDI lookup. - initialContext = new InitialContext(); - - // Step 2. Look-up the JMS topic - Topic topic = (Topic) initialContext.lookup("topic/exampleTopic"); - - // Step 3. Look-up the JMS connection factory - ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("ConnectionFactory"); - - // Step 4. Create a JMS connection - connection = cf.createConnection(); - - // Step 5. Create a JMS session - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - - // Step 6. Create a JMS message producer - MessageProducer producer = session.createProducer(topic); - - // Step 7. Create one subscription with a specific Filter for someID=1 - MessageConsumer messageConsumer1 = session.createConsumer(topic, "someID=1", false); - - // Step 8. Create another subscription with a specific Filter for someID=2 - MessageConsumer messageConsumer2 = session.createConsumer(topic, "someID=2", false); - - // Step 9. Create another subscription with no filters, which will receive every message sent to the topic - MessageConsumer messageConsumer3 = session.createConsumer(topic); - - // Step 10. Send 20 messages, 10 with someID=1, 10 with someID=2 - - for (int i = 1; i < 10; i++) { - for (int someID = 1; someID <= 2; someID++) { - // Step 10.1 Create a text message - TextMessage message1 = session.createTextMessage("This is a text message " + i + - " sent for someID=" + - someID); - - // Step 10.1 Set a property - message1.setIntProperty("someID", someID); - - // Step 10.2 Send the message - producer.send(message1); - - System.out.println("Sent message: " + message1.getText()); - } - } - - // Step 11. Start the JMS Connection. This step will activate the subscribers to receive messages. - connection.start(); - - // Step 12. Consume the messages from MessageConsumer1, filtering out someID=2 - - System.out.println("*************************************************************"); - System.out.println("MessageConsumer1 will only receive messages where someID=1:"); - for (;;) { - TextMessage messageReceivedA = (TextMessage) messageConsumer1.receive(1000); - if (messageReceivedA == null) { - break; - } - - System.out.println("messageConsumer1 received " + messageReceivedA.getText() + - " someID = " + - messageReceivedA.getIntProperty("someID")); - } - - // Step 13. Consume the messages from MessageConsumer2, filtering out someID=2 - System.out.println("*************************************************************"); - System.out.println("MessageConsumer2 will only receive messages where someID=2:"); - for (;;) { - TextMessage messageReceivedB = (TextMessage) messageConsumer2.receive(1000); - if (messageReceivedB == null) { - break; - } - - System.out.println("messageConsumer2 received " + messageReceivedB.getText() + - " someID = " + - messageReceivedB.getIntProperty("someID")); - } - - // Step 14. Consume the messages from MessageConsumer3, receiving the complete set of messages - System.out.println("*************************************************************"); - System.out.println("MessageConsumer3 will receive every message:"); - for (;;) { - TextMessage messageReceivedC = (TextMessage) messageConsumer3.receive(1000); - if (messageReceivedC == null) { - break; - } - System.out.println("messageConsumer3 received " + messageReceivedC.getText() + - " someID = " + - messageReceivedC.getIntProperty("someID")); - } - - // Step 15. Close the subscribers - messageConsumer1.close(); - messageConsumer2.close(); - messageConsumer3.close(); - } - finally { - // Step 15. Be sure to close our JMS resources! - if (initialContext != null) { - initialContext.close(); - } - if (connection != null) { - connection.close(); - } - } - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/topic-selector-example1/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/jms/topic-selector-example1/src/main/resources/activemq/server0/broker.xml b/examples/jms/topic-selector-example1/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index d45eb5d..0000000 --- a/examples/jms/topic-selector-example1/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,60 +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> - - <!-- Acceptors --> - <acceptors> - <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor> - </acceptors> - - <!-- Other config --> - - <security-settings> - <!--security for example topic--> - <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/topic-selector-example1/src/main/resources/jndi.properties ---------------------------------------------------------------------- diff --git a/examples/jms/topic-selector-example1/src/main/resources/jndi.properties b/examples/jms/topic-selector-example1/src/main/resources/jndi.properties deleted file mode 100644 index 54bed6d..0000000 --- a/examples/jms/topic-selector-example1/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 -topic.topic/exampleTopic=exampleTopic http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/topic-selector-example2/pom.xml ---------------------------------------------------------------------- diff --git a/examples/jms/topic-selector-example2/pom.xml b/examples/jms/topic-selector-example2/pom.xml deleted file mode 100644 index cd23209..0000000 --- a/examples/jms/topic-selector-example2/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.jms</groupId> - <artifactId>jms-examples</artifactId> - <version>1.0.1-SNAPSHOT</version> - </parent> - - <artifactId>topic-selector2</artifactId> - <packaging>jar</packaging> - <name>ActiveMQ Artemis JMS Topic Selector Example 2</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>create</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - </configuration> - </execution> - <execution> - <id>start</id> - <goals> - <goal>cli</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <spawn>true</spawn> - <testURI>tcp://localhost:61616</testURI> - <args> - <param>run</param> - </args> - </configuration> - </execution> - <execution> - <id>runClient</id> - <goals> - <goal>runClient</goal> - </goals> - <configuration> - <clientClass>org.apache.activemq.artemis.jms.example.TopicSelectorExample2</clientClass> - </configuration> - </execution> - <execution> - <id>stop</id> - <goals> - <goal>cli</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <args> - <param>stop</param> - </args> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.apache.activemq.examples.jms</groupId> - <artifactId>topic-selector2</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/topic-selector-example2/readme.html ---------------------------------------------------------------------- diff --git a/examples/jms/topic-selector-example2/readme.html b/examples/jms/topic-selector-example2/readme.html deleted file mode 100644 index 8cb82c2..0000000 --- a/examples/jms/topic-selector-example2/readme.html +++ /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. ---> - -<html> - <head> - <title>ActiveMQ Artemis JMS Topic Selector Example 2</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 Topic Selector Example 2</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 shows you how to selectively consume messages using message selectors with topic consumers.</p> - - <p>Message selectors are strings with special syntax that can be used in creating consumers. Message consumers - that are thus created only receive messages that match its selector. On message delivering, the ActiveMQ - Server evaluates the corresponding message headers of the messages against each selector, if any, and then delivers - the 'matched' messages to its consumer. Please consult the JMS 1.1 specification for full details.</p> - - <p>In this example, three message consumers are created on a topic. The first consumer is created with selector - <code>'color=red'</code>, it only receives messages that - have a 'color' string property of 'red' value; the second is created with selector <code>'color=green'</code>, it - only receives messages who have a 'color' string property of - 'green' value; and the third without a selector, which means it receives all messages. To illustrate, three messages - with different 'color' property values are created and sent.</p> - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/topic-selector-example2/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample2.java ---------------------------------------------------------------------- diff --git a/examples/jms/topic-selector-example2/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample2.java b/examples/jms/topic-selector-example2/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample2.java deleted file mode 100644 index 464b21b..0000000 --- a/examples/jms/topic-selector-example2/src/main/java/org/apache/activemq/artemis/jms/example/TopicSelectorExample2.java +++ /dev/null @@ -1,145 +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.JMSException; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageListener; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TextMessage; -import javax.jms.Topic; -import javax.naming.InitialContext; -import java.util.concurrent.atomic.AtomicBoolean; - -/** - * A simple JMS example that consumes messages using selectors. - */ -public class TopicSelectorExample2 { - - public static void main(final String[] args) throws Exception { - AtomicBoolean result = new AtomicBoolean(true); - Connection connection = null; - InitialContext initialContext = null; - try { - // /Step 1. Create an initial context to perform the JNDI lookup. - initialContext = new InitialContext(); - - // Step 2. perform a lookup on the topic - Topic topic = (Topic) initialContext.lookup("topic/exampleTopic"); - - // Step 3. perform a lookup on the Connection Factory - ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("ConnectionFactory"); - - // Step 4. Create a JMS Connection - connection = cf.createConnection(); - - // Step 5. Start the Connection - connection.start(); - - // Step 6. Create a JMS Session - Session producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - - // Step 7. Create a Message Producer - MessageProducer producer = producerSession.createProducer(topic); - - // Step 8. Prepare two selectors - String redSelector = "color='red'"; - String greenSelector = "color='green'"; - - // Step 9. Create a JMS Message Consumer that receives 'red' messages - Session redSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageConsumer redConsumer = redSession.createConsumer(topic, redSelector); - redConsumer.setMessageListener(new SimpleMessageListener("red", result)); - - // Step 10. Create a second JMS message consumer that receives 'green' messages - Session greenSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageConsumer greenConsumer = greenSession.createConsumer(topic, greenSelector); - greenConsumer.setMessageListener(new SimpleMessageListener("green", result)); - - // Step 11. Create another JMS message consumer that receives all messages. - Session allSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - MessageConsumer allConsumer = allSession.createConsumer(topic); - allConsumer.setMessageListener(new SimpleMessageListener("all", result)); - - // Step 12. Create three messages, each has a color property - TextMessage redMessage = producerSession.createTextMessage("Red"); - redMessage.setStringProperty("color", "red"); - TextMessage greenMessage = producerSession.createTextMessage("Green"); - greenMessage.setStringProperty("color", "green"); - TextMessage blueMessage = producerSession.createTextMessage("Blue"); - blueMessage.setStringProperty("color", "blue"); - - // Step 13. Send the Messages - producer.send(redMessage); - System.out.println("Message sent: " + redMessage.getText()); - producer.send(greenMessage); - System.out.println("Message sent: " + greenMessage.getText()); - producer.send(blueMessage); - System.out.println("Message sent: " + blueMessage.getText()); - - Thread.sleep(5000); - - if (!result.get()) - throw new IllegalStateException(); - } - finally { - // Step 14. Be sure to close our JMS resources! - if (connection != null) { - connection.close(); - } - - // Also the initialContext - if (initialContext != null) { - initialContext.close(); - } - } - } -} - -class SimpleMessageListener implements MessageListener { - - private final String name; - AtomicBoolean result; - - public SimpleMessageListener(final String listener, AtomicBoolean result) { - name = listener; - this.result = result; - } - - public void onMessage(final Message msg) { - TextMessage textMessage = (TextMessage) msg; - try { - String colorProp = msg.getStringProperty("color"); - System.out.println("Receiver " + name + - " receives message [" + - textMessage.getText() + - "] with color property: " + - colorProp); - if (!colorProp.equals(name) && !name.equals("all")) { - result.set(false); - } - } - catch (JMSException e) { - e.printStackTrace(); - result.set(false); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/topic-selector-example2/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/jms/topic-selector-example2/src/main/resources/activemq/server0/broker.xml b/examples/jms/topic-selector-example2/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index d45eb5d..0000000 --- a/examples/jms/topic-selector-example2/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,60 +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> - - <!-- Acceptors --> - <acceptors> - <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor> - </acceptors> - - <!-- Other config --> - - <security-settings> - <!--security for example topic--> - <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/topic-selector-example2/src/main/resources/jndi.properties ---------------------------------------------------------------------- diff --git a/examples/jms/topic-selector-example2/src/main/resources/jndi.properties b/examples/jms/topic-selector-example2/src/main/resources/jndi.properties deleted file mode 100644 index 54bed6d..0000000 --- a/examples/jms/topic-selector-example2/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 -topic.topic/exampleTopic=exampleTopic http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/topic/pom.xml ---------------------------------------------------------------------- diff --git a/examples/jms/topic/pom.xml b/examples/jms/topic/pom.xml deleted file mode 100644 index 7e5005e..0000000 --- a/examples/jms/topic/pom.xml +++ /dev/null @@ -1,117 +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>topic</artifactId> - <packaging>jar</packaging> - <name>ActiveMQ Artemis JMS 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>create</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - </configuration> - </execution> - <execution> - <id>start</id> - <goals> - <goal>cli</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <spawn>true</spawn> - <testURI>tcp://localhost:61616</testURI> - <args> - <param>run</param> - </args> - </configuration> - </execution> - <execution> - <id>runClient</id> - <goals> - <goal>runClient</goal> - </goals> - <configuration> - <clientClass>org.apache.activemq.artemis.jms.example.TopicExample</clientClass> - </configuration> - </execution> - <execution> - <id>stop</id> - <goals> - <goal>cli</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <args> - <param>stop</param> - </args> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.apache.activemq.examples.jms</groupId> - <artifactId>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/topic/readme.html ---------------------------------------------------------------------- diff --git a/examples/jms/topic/readme.html b/examples/jms/topic/readme.html deleted file mode 100644 index 45358cb..0000000 --- a/examples/jms/topic/readme.html +++ /dev/null @@ -1,36 +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 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 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 shows you how to send and receive a message to a JMS Topic with ActiveMQ Artemis.</p> - <p>Topics are a standard part of JMS, please consult the JMS 1.1 specification for full details.</p> - <p>A Topic is used to send messages using the publish-subscribe model, from a producer to 1 or more consumers.</p> - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/topic/src/main/java/org/apache/activemq/artemis/jms/example/TopicExample.java ---------------------------------------------------------------------- diff --git a/examples/jms/topic/src/main/java/org/apache/activemq/artemis/jms/example/TopicExample.java b/examples/jms/topic/src/main/java/org/apache/activemq/artemis/jms/example/TopicExample.java deleted file mode 100644 index 1c8695b..0000000 --- a/examples/jms/topic/src/main/java/org/apache/activemq/artemis/jms/example/TopicExample.java +++ /dev/null @@ -1,94 +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; - -/** - * A simple JMS Topic example that creates a producer and consumer on a queue and sends and receives a message. - */ -public class TopicExample { - - public static void main(final String[] args) throws Exception { - Connection connection = null; - InitialContext initialContext = null; - try { - // /Step 1. Create an initial context to perform the JNDI lookup. - initialContext = new InitialContext(); - - // Step 2. perform a lookup on the topic - Topic topic = (Topic) initialContext.lookup("topic/exampleTopic"); - - // Step 3. perform a lookup on the Connection Factory - ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("ConnectionFactory"); - - // Step 4. Create a JMS Connection - connection = cf.createConnection(); - - // Step 5. Create a JMS Session - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - - // Step 6. Create a Message Producer - MessageProducer producer = session.createProducer(topic); - - // Step 7. Create a JMS Message Consumer - MessageConsumer messageConsumer1 = session.createConsumer(topic); - - // Step 8. Create a JMS Message Consumer - MessageConsumer messageConsumer2 = session.createConsumer(topic); - - // Step 9. Create a Text Message - TextMessage message = session.createTextMessage("This is a text message"); - - System.out.println("Sent message: " + message.getText()); - - // Step 10. Send the Message - producer.send(message); - - // Step 11. Start the Connection - connection.start(); - - // Step 12. Receive the message - TextMessage messageReceived = (TextMessage) messageConsumer1.receive(); - - System.out.println("Consumer 1 Received message: " + messageReceived.getText()); - - // Step 13. Receive the message - messageReceived = (TextMessage) messageConsumer2.receive(); - - System.out.println("Consumer 2 Received message: " + messageReceived.getText()); - } - finally { - // Step 14. Be sure to close our JMS resources! - if (connection != null) { - connection.close(); - } - - // Also the initialContext - if (initialContext != null) { - initialContext.close(); - } - } - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/topic/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/jms/topic/src/main/resources/activemq/server0/broker.xml b/examples/jms/topic/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index fd6671c..0000000 --- a/examples/jms/topic/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,59 +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> - - <!-- Acceptors --> - <acceptors> - <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor> - </acceptors> - - <!-- Other config --> - <security-settings> - <!--security for example topic--> - <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/topic/src/main/resources/jndi.properties ---------------------------------------------------------------------- diff --git a/examples/jms/topic/src/main/resources/jndi.properties b/examples/jms/topic/src/main/resources/jndi.properties deleted file mode 100644 index 54bed6d..0000000 --- a/examples/jms/topic/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 -topic.topic/exampleTopic=exampleTopic http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/transaction-failover/pom.xml ---------------------------------------------------------------------- diff --git a/examples/jms/transaction-failover/pom.xml b/examples/jms/transaction-failover/pom.xml deleted file mode 100644 index d5bc653..0000000 --- a/examples/jms/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.jms</groupId> - <artifactId>jms-examples</artifactId> - <version>1.0.1-SNAPSHOT</version> - </parent> - - <artifactId>transaction-failover</artifactId> - <packaging>jar</packaging> - <name>ActiveMQ Artemis JMS 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.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.TransactionFailoverExample</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>transaction-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/transaction-failover/readme.html ---------------------------------------------------------------------- diff --git a/examples/jms/transaction-failover/readme.html b/examples/jms/transaction-failover/readme.html deleted file mode 100644 index 5df44bd..0000000 --- a/examples/jms/transaction-failover/readme.html +++ /dev/null @@ -1,46 +0,0 @@ -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<html> - <head> - <title>ActiveMQ Artemis JMS Failover With Transaction Example</title> - <link rel="stylesheet" type="text/css" href="../common/common.css" /> - <link rel="stylesheet" type="text/css" href="../common/prettify.css" /> - <script type="text/javascript" src="../common/prettify.js"></script> - </head> - <body onload="prettyPrint()"> - <h1>JMS Failover With Transaction Example</h1> - - <pre>To run the example, simply type <b>mvn verify</b> from this directory.</pre> - - - <p>This example demonstrates two servers coupled as a live-backup pair for high availability (HA), and a client - connection failing over from live to backup when the live server is crashed.</p> - <p>Failover behavior differs whether the JMS session is transacter or not.</p> - <p>When a <em>transacted</em> JMS session is used, once-and-only once delivery is guaranteed.</p> - <ul> - <li>if the failover occurs while there is an in-flight transaction, the transaction will be flagged as <em>rollback only</em>. In that case, the JMS client - will need to retry the transaction work.</li> - <li>if the failover occurs while there is <em>no</em> in-flight transaction, the failover will be transparent to the user.</li> - </ul> - <p>ActiveMQ Artemis also provides an example for <a href="../non-transactional-failover/readme.html">non-transaction failover</a>.</p> - <p>For more information on ActiveMQ Artemis failover and HA, and clustering in general, please see the clustering - section of the user manual.</p> - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/TransactionFailoverExample.java ---------------------------------------------------------------------- diff --git a/examples/jms/transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/TransactionFailoverExample.java b/examples/jms/transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/TransactionFailoverExample.java deleted file mode 100644 index 58c514a..0000000 --- a/examples/jms/transaction-failover/src/main/java/org/apache/activemq/artemis/jms/example/TransactionFailoverExample.java +++ /dev/null @@ -1,167 +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.api.core.Message; -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.jms.TransactionRolledBackException; -import javax.naming.InitialContext; - -/** - * A simple example that demonstrates failover of the JMS connection from one node to another - * when the live server crashes using a JMS <em>transacted</em> session. - */ -public class TransactionFailoverExample { - - // You need to guarantee uniqueIDs when using duplicate detection - // It needs to be unique even after a restart - // as these IDs are stored on the journal for control - // We recommend some sort of UUID, but for this example the Current Time as string would be enough - static String uniqueID = Long.toString(System.currentTimeMillis()); - - private static Process server0; - - private static Process server1; - - public static void main(final String[] args) throws Exception { - final int numMessages = 10; - - Connection connection = null; - - InitialContext initialContext = null; - - try { - server0 = ServerUtil.startServer(args[0], TransactionFailoverExample.class.getSimpleName() + "0", 0, 5000); - server1 = ServerUtil.startServer(args[1], TransactionFailoverExample.class.getSimpleName() + "1", 1, 5000); - - // 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. We create a JMS Connection - connection = connectionFactory.createConnection(); - - // Step 4. We create a *transacted* JMS Session - Session session = connection.createSession(true, 0); - - // Step 5. We start the connection to ensure delivery occurs - connection.start(); - - // Step 6. We create a JMS MessageProducer - MessageProducer producer = session.createProducer(queue); - - // Step 7. We create a JMS MessageConsumer - MessageConsumer consumer = session.createConsumer(queue); - - // Step 8. We send half of the messages, kill the live server and send the remaining messages - sendMessages(session, producer, numMessages, true); - - // Step 9. As failover occurred during transaction, the session has been marked for rollback only - try { - session.commit(); - } - catch (TransactionRolledBackException e) { - System.err.println("transaction has been rolled back: " + e.getMessage()); - } - - // Step 10. We resend all the messages - sendMessages(session, producer, numMessages, false); - - // Step 11. We commit the session successfully: the messages will be all delivered to the activated backup - // server - session.commit(); - - // Step 12. We are now transparently reconnected to server #0, the backup server. - // We consume the messages sent before the crash of the live server and commit the session. - for (int i = 0; i < numMessages; i++) { - TextMessage message0 = (TextMessage) consumer.receive(5000); - - if (message0 == null) { - throw new IllegalStateException("Example failed - message wasn't received"); - } - - System.out.println("Got message: " + message0.getText()); - } - - session.commit(); - - System.out.println("Other message on the server? " + consumer.receive(5000)); - } - 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); - } - } - - private static void sendMessages(final Session session, - final MessageProducer producer, - final int numMessages, - final boolean killServer) throws Exception { - - // We send half of messages - for (int i = 0; i < numMessages / 2; i++) { - TextMessage message = session.createTextMessage("This is text message " + i); - - message.setStringProperty(Message.HDR_DUPLICATE_DETECTION_ID.toString(), uniqueID + i); - - producer.send(message); - - System.out.println("Sent message: " + message.getText()); - } - - if (killServer) { - Thread.sleep(5000); - - ServerUtil.killServer(server0); - } - - // We send the remaining half of messages - for (int i = numMessages / 2; i < numMessages; i++) { - TextMessage message = session.createTextMessage("This is text message " + i); - - // We set the duplicate detection header - so the server will ignore the same message - // if sent again after failover - - message.setStringProperty(Message.HDR_DUPLICATE_DETECTION_ID.toString(), uniqueID + i); - - producer.send(message); - - System.out.println("Sent message: " + message.getText()); - } - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/transaction-failover/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/jms/transaction-failover/src/main/resources/activemq/server0/broker.xml b/examples/jms/transaction-failover/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 916fdf5..0000000 --- a/examples/jms/transaction-failover/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,98 +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> - <shared-store> - <master> - <failover-on-shutdown>true</failover-on-shutdown> - </master> - </shared-store> - </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>
