You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2015/08/13 06:13:57 UTC
[39/48] activemq-artemis git commit: renaming broker-features ->
features on examples
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/bridge/pom.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/bridge/pom.xml b/examples/broker-features/standard/bridge/pom.xml
deleted file mode 100644
index db1caf8..0000000
--- a/examples/broker-features/standard/bridge/pom.xml
+++ /dev/null
@@ -1,167 +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.broker</groupId>
- <artifactId>jms-examples</artifactId>
- <version>1.0.1-SNAPSHOT</version>
- </parent>
-
- <artifactId>core-bridge</artifactId>
- <packaging>jar</packaging>
- <name>ActiveMQ Artemis Core Bridge Example</name>
-
- <properties>
- <activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-server</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>
- <libList>
- <!-- For the transformer -->
- <arg>org.apache.activemq.examples.broker:core-bridge:${project.version}</arg>
- </libList>
- <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>
- <libList>
- <!-- For the transformer -->
- <arg>org.apache.activemq.examples.broker:core-bridge:${project.version}</arg>
- </libList>
- <ignore>${noServer}</ignore>
- <instance>${basedir}/target/server1</instance>
- <configuration>${basedir}/target/classes/activemq/server1</configuration>
- <portOffset>1</portOffset>
- </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.BridgeExample</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.broker</groupId>
- <artifactId>core-bridge</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/bridge/readme.html
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/bridge/readme.html b/examples/broker-features/standard/bridge/readme.html
deleted file mode 100644
index 698c6c2..0000000
--- a/examples/broker-features/standard/bridge/readme.html
+++ /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.
--->
-
-<html>
- <head>
- <title>ActiveMQ Artemis Core Bridge 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>Core Bridge 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 core bridge deployed on one server, which consumes messages from a
- local queue and forwards them to an address on a second server.</p>
-
- <p>Core bridges are used to create message flows between any two ActiveMQ Artemis servers which are remotely separated.
- Core bridges are resilient and will cope with temporary connection failure allowing them to be an ideal
- choice for forwarding over unreliable connections, e.g. a WAN.</p>
- <p>They can also be configured with an optional filter expression, and will only forward messages that
- match that filter.</p>
- <p>Furthermore they can be configured to use an optional Transformer class. A user-defined Transformer class
- can be specified which is called at forwarding time. This gives the user the opportunity to transform
- the message in some ways, e.g. changing its properties or body</p>
- <p>ActiveMQ Artemis also includes a <b>JMS Bridge</b>. This is similar to a core bridge, but uses the JMS API
- and can be used to bridge between any two JMS 1.1 compliant messaging systems. The core bridge is limited to bridging
- between ActiveMQ Artemis instances, but may provide better performance than the JMS bridge. The JMS bridge is covered in
- a separate example.</p>
- <p>For more information on bridges, please see the ActiveMQ Artemis user manual.</p>
-
- <p>In this example we will demonstrate a simple sausage factory for aardvarks.</p>
- <p>We have a JMS queue on server 0 named <code>sausage-factory</code>, and we have a
- JMS queue on server 1 named <code>mincing-machine</code></p>
- <p>We want to forward any messages that are sent to the <code>sausage-factory</code> queue on server 0, to the <code>mincing-machine</code>
- on server 1.</p>
- <p>We only want to make aardvark sausages, so we only forward messages where the property "name" is set
- to "aardvark". It is known that other things, such are Sasquatches are also sent to the <code>sausage-factory</code> and we
- want to reject those.</p>
- <p>Moreover it is known that Aardvarks normally wear blue hats, and it's important that we only make sausages using
- Aardvarks with green hats, so on the way we are going transform the property "hat" from "green" to "blue".</p>
- <p>Here's a snippet from <code>broker.xml</code> showing the bridge configuration</p>
- <pre class="prettyprint">
- <code>
- <bridge name="my-bridge">
- <queue-name>jms.queue.sausage-factory</queue-name>
- <forwarding-address>jms.queue.mincing-machine</forwarding-address>
- <filter string="name='aardvark'"/>
- <transformer-class-name>org.apache.activemq.artemis.jms.example.HatColourChangeTransformer</transformer-class-name>
- <reconnect-attempts>-1</reconnect-attempts>
- <static-connectors>
- <connector-ref>remote-connector</connector-ref>
- </static-connectors>
- </bridge>
- </code>
- </pre>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/bridge/src/main/java/org/apache/activemq/artemis/jms/example/BridgeExample.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/bridge/src/main/java/org/apache/activemq/artemis/jms/example/BridgeExample.java b/examples/broker-features/standard/bridge/src/main/java/org/apache/activemq/artemis/jms/example/BridgeExample.java
deleted file mode 100644
index 0fa17c2..0000000
--- a/examples/broker-features/standard/bridge/src/main/java/org/apache/activemq/artemis/jms/example/BridgeExample.java
+++ /dev/null
@@ -1,175 +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.Queue;
-import javax.jms.Session;
-import javax.naming.InitialContext;
-import java.util.Hashtable;
-
-/**
- * This example demonstrates a core bridge set-up between two nodes, consuming messages from a queue
- * on one node and forwarding them to an address on the second node.
- */
-public class BridgeExample {
-
- public static void main(final String[] args) throws Exception {
- Connection connection0 = null;
-
- Connection connection1 = null;
-
- InitialContext ic0 = null;
-
- InitialContext ic1 = null;
-
- try {
- // Step 1 - we create an initial context for looking up JNDI on node 0
-
- 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://127.0.0.1:61616");
- properties.put("queue.queue/sausage-factory", "sausage-factory");
- ic0 = new InitialContext(properties);
-
- // Step 2 - we look up the sausage-factory queue from node 0
-
- Queue sausageFactory = (Queue) ic0.lookup("queue/sausage-factory");
-
- // Step 3 - we look up a JMS ConnectionFactory object from node 0
-
- ConnectionFactory cf0 = (ConnectionFactory) ic0.lookup("ConnectionFactory");
-
- // Step 4 - we create an initial context for looking up JNDI on node 1
-
- properties = new Hashtable<String, Object>();
- properties.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
- properties.put("connectionFactory.ConnectionFactory", "tcp://127.0.0.1:61617");
- properties.put("queue.queue/mincing-machine", "mincing-machine");
- ic1 = new InitialContext(properties);
-
- // Step 5 - we look up the mincing-machine queue on node 1
-
- Queue mincingMachine = (Queue) ic1.lookup("queue/mincing-machine");
-
- // Step 6 - we look up a JMS ConnectionFactory object from node 1
-
- ConnectionFactory cf1 = (ConnectionFactory) ic1.lookup("ConnectionFactory");
-
- // Step 7. We create a JMS Connection connection0 which is a connection to server 0
-
- connection0 = cf0.createConnection();
-
- // Step 8. We create a JMS Connection connection1 which is a connection to server 1
- connection1 = cf1.createConnection();
-
- // Step 9. We create a JMS Session on server 0
-
- Session session0 = connection0.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- // Step 10. We create a JMS Session on server 1
-
- Session session1 = connection1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- // Step 10. We start the connection to ensure delivery occurs on them
-
- connection1.start();
-
- // Step 11. We create JMS MessageConsumer object
- MessageConsumer consumer = session1.createConsumer(mincingMachine);
-
- // Step 12. We create a JMS MessageProducer object on server 0
- MessageProducer producer = session0.createProducer(sausageFactory);
-
- // Step 13. We create and send a message representing an aardvark with a green hat to the sausage-factory
- // on node 0
- Message message = session0.createMessage();
-
- message.setStringProperty("name", "aardvark");
-
- message.setStringProperty("hat", "green");
-
- producer.send(message);
-
- System.out.println("Sent " + message.getStringProperty("name") +
- " message with " +
- message.getStringProperty("hat") +
- " hat to sausage-factory on node 0");
-
- // Step 14 - we successfully receive the aardvark message from the mincing-machine one node 1. The aardvark's
- // hat is now blue since it has been transformed!
-
- Message receivedMessage = consumer.receive(5000);
-
- System.out.println("Received " + receivedMessage.getStringProperty("name") +
- " message with " +
- receivedMessage.getStringProperty("hat") +
- " hat from mincing-machine on node 1");
-
- // Step 13. We create and send another message, this time representing a sasquatch with a mauve hat to the
- // sausage-factory on node 0. This won't be bridged to the mincing-machine since we only want aardvarks, not
- // sasquatches
-
- message = session0.createMessage();
-
- message.setStringProperty("name", "sasquatch");
-
- message.setStringProperty("hat", "mauve");
-
- producer.send(message);
-
- System.out.println("Sent " + message.getStringProperty("name") +
- " message with " +
- message.getStringProperty("hat") +
- " hat to sausage-factory on node 0");
-
- // Step 14. We don't receive the message since it has not been bridged.
-
- receivedMessage = consumer.receive(1000);
-
- if (receivedMessage == null) {
- System.out.println("Didn't receive that message from mincing-machine on node 1");
- }
- else {
- throw new IllegalStateException();
- }
- }
- finally {
- // Step 15. Be sure to close our 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/6b17d966/examples/broker-features/standard/bridge/src/main/java/org/apache/activemq/artemis/jms/example/HatColourChangeTransformer.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/bridge/src/main/java/org/apache/activemq/artemis/jms/example/HatColourChangeTransformer.java b/examples/broker-features/standard/bridge/src/main/java/org/apache/activemq/artemis/jms/example/HatColourChangeTransformer.java
deleted file mode 100644
index ae8cf39..0000000
--- a/examples/broker-features/standard/bridge/src/main/java/org/apache/activemq/artemis/jms/example/HatColourChangeTransformer.java
+++ /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.
- */
-package org.apache.activemq.artemis.jms.example;
-
-import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.server.ServerMessage;
-import org.apache.activemq.artemis.core.server.cluster.Transformer;
-
-public class HatColourChangeTransformer implements Transformer {
-
- public ServerMessage transform(final ServerMessage message) {
- SimpleString propName = new SimpleString("hat");
-
- SimpleString oldProp = message.getSimpleStringProperty(propName);
-
- // System.out.println("Old hat colour is " + oldProp);
-
- // Change the colour
- message.putStringProperty(propName, new SimpleString("blue"));
-
- return message;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/bridge/src/main/resources/activemq/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/bridge/src/main/resources/activemq/server0/broker.xml b/examples/broker-features/standard/bridge/src/main/resources/activemq/server0/broker.xml
deleted file mode 100644
index 250a851..0000000
--- a/examples/broker-features/standard/bridge/src/main/resources/activemq/server0/broker.xml
+++ /dev/null
@@ -1,88 +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="sausage-factory"/>
- </jms>
-
- <core xmlns="urn:activemq:core">
-
- <bindings-directory>${data.dir}/server0/data/messaging/bindings</bindings-directory>
-
- <journal-directory>${data.dir}/server0/data/messaging/journal</journal-directory>
-
- <large-messages-directory>${data.dir}/server0/data/messaging/largemessages</large-messages-directory>
-
- <paging-directory>${data.dir}/server0/data/messaging/paging</paging-directory>
-
- <!-- Connectors -->
- <connectors>
- <!-- Connector to the other node -->
- <connector name="remote-connector">tcp://localhost:61617</connector>
- </connectors>
-
- <!-- Acceptors -->
- <acceptors>
- <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor>
- </acceptors>
-
- <!-- We need to create a core queue for the JMS queue explicitly because the bridge will be deployed
- before the JMS queue is deployed, so the first time, it otherwise won't find the queue -->
- <queues>
- <queue name="jms.queue.sausage-factory">
- <address>jms.queue.sausage-factory</address>
- </queue>
- </queues>
-
- <!-- We set-up a bridge that forwards from a queue on this node to an address on another node.
- We specify a filter with the bridge, and a transformer too. The filter and transformer are optional -->
- <bridges>
- <bridge name="my-bridge">
- <queue-name>jms.queue.sausage-factory</queue-name>
- <forwarding-address>jms.queue.mincing-machine</forwarding-address>
- <filter string="name='aardvark'"/>
- <transformer-class-name>org.apache.activemq.artemis.jms.example.HatColourChangeTransformer</transformer-class-name>
- <reconnect-attempts>-1</reconnect-attempts>
- <static-connectors>
- <connector-ref>remote-connector</connector-ref>
- </static-connectors>
- </bridge>
- </bridges>
-
- <!-- Other config -->
-
- <security-settings>
- <!--security for example queue-->
- <security-setting match="jms.queue.#">
- <permission type="createDurableQueue" roles="guest"/>
- <permission type="deleteDurableQueue" roles="guest"/>
- <permission type="createNonDurableQueue" roles="guest"/>
- <permission type="deleteNonDurableQueue" roles="guest"/>
- <permission type="consume" roles="guest"/>
- <permission type="send" roles="guest"/>
- </security-setting>
- </security-settings>
- </core>
-
-</configuration>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/bridge/src/main/resources/activemq/server1/broker.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/bridge/src/main/resources/activemq/server1/broker.xml b/examples/broker-features/standard/bridge/src/main/resources/activemq/server1/broker.xml
deleted file mode 100644
index 516f179..0000000
--- a/examples/broker-features/standard/bridge/src/main/resources/activemq/server1/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 queue used by the example-->
- <queue name="mincing-machine"/>
- </jms>
- <core xmlns="urn:activemq:core">
-
- <bindings-directory>${data.dir}/server1/data/messaging/bindings</bindings-directory>
-
- <journal-directory>${data.dir}/server1/data/messaging/journal</journal-directory>
-
- <large-messages-directory>${data.dir}/server1/data/messaging/largemessages</large-messages-directory>
-
- <paging-directory>${data.dir}/server1/data/messaging/paging</paging-directory>
-
- <!-- Acceptors -->
- <acceptors>
- <acceptor name="netty-acceptor">tcp://localhost:61617</acceptor>
- </acceptors>
-
- <!-- Other config -->
-
- <security-settings>
- <!--security for example queue-->
- <security-setting match="jms.queue.#">
- <permission type="createDurableQueue" roles="guest"/>
- <permission type="deleteDurableQueue" roles="guest"/>
- <permission type="createNonDurableQueue" roles="guest"/>
- <permission type="deleteNonDurableQueue" roles="guest"/>
- <permission type="consume" roles="guest"/>
- <permission type="send" roles="guest"/>
- </security-setting>
- </security-settings>
- </core>
-
-</configuration>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/browser/pom.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/browser/pom.xml b/examples/broker-features/standard/browser/pom.xml
deleted file mode 100644
index 7ab1299..0000000
--- a/examples/broker-features/standard/browser/pom.xml
+++ /dev/null
@@ -1,110 +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.broker</groupId>
- <artifactId>jms-examples</artifactId>
- <version>1.0.1-SNAPSHOT</version>
- </parent>
-
- <artifactId>browser</artifactId>
- <packaging>jar</packaging>
- <name>ActiveMQ Artemis JMS Browser 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>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>create</id>
- <phase>verify</phase>
- <configuration>
- <ignore>${noServer}</ignore>
- </configuration>
- <goals>
- <goal>create</goal>
- </goals>
- </execution>
- <execution>
- <id>start</id>
- <goals>
- <goal>cli</goal>
- </goals>
- <configuration>
- <spawn>true</spawn>
- <ignore>${noServer}</ignore>
- <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.QueueBrowserExample</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.broker</groupId>
- <artifactId>browser</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/browser/readme.html
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/browser/readme.html b/examples/broker-features/standard/browser/readme.html
deleted file mode 100644
index 9f9e01a..0000000
--- a/examples/broker-features/standard/browser/readme.html
+++ /dev/null
@@ -1,40 +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 QueueBrowser 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 QueueBrowser 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 use a JMS <a href="http://java.sun.com/javaee/5/docs/api/javax/jms/QueueBrowser.html">QueueBrowser</a> with ActiveMQ Artemis.<br />
- Queues are a standard part of JMS, please consult the JMS 1.1 specification for full details.<br />
- A QueueBrowser is used to look at messages on the queue without removing them.
- It can scan the entire content of a queue or only messages matching a message selector.</p>
- <p>
- The example will send 2 messages on a queue, use a QueueBrowser to browse
- the queue (looking at the message without removing them) and finally consume the 2 messages
- </p>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/browser/src/main/java/org/apache/activemq/artemis/jms/example/QueueBrowserExample.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/browser/src/main/java/org/apache/activemq/artemis/jms/example/QueueBrowserExample.java b/examples/broker-features/standard/browser/src/main/java/org/apache/activemq/artemis/jms/example/QueueBrowserExample.java
deleted file mode 100644
index 1c9db3b..0000000
--- a/examples/broker-features/standard/browser/src/main/java/org/apache/activemq/artemis/jms/example/QueueBrowserExample.java
+++ /dev/null
@@ -1,103 +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.Queue;
-import javax.jms.QueueBrowser;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.naming.InitialContext;
-import java.util.Enumeration;
-
-/**
- * A simple example which shows how to use a QueueBrowser to look at messages of a queue without removing them from the queue
- */
-public class QueueBrowserExample {
-
- 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. Perfom a lookup on the queue
- Queue queue = (Queue) initialContext.lookup("queue/exampleQueue");
-
- // Step 3. Perform a lookup on the Connection Factory
- // you could alternatively instantiate the connection directly
- // ConnectionFactory cf = new ActiveMQConnectionFactory(); // this would accept the broker URI as well
- 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(queue);
-
- // Step 7. Create 2 Text Messages
- TextMessage message_1 = session.createTextMessage("this is the 1st message");
- TextMessage message_2 = session.createTextMessage("this is the 2nd message");
-
- // Step 8. Send the Message
- producer.send(message_1);
- producer.send(message_2);
-
- // Step 9. Create the JMS QueueBrowser
- QueueBrowser browser = session.createBrowser(queue);
-
- // Step 10. Browse the messages on the queue
- // Browsing a queue does not remove the messages from the queue
- Enumeration messageEnum = browser.getEnumeration();
- while (messageEnum.hasMoreElements()) {
- TextMessage message = (TextMessage) messageEnum.nextElement();
- System.out.println("Browsing: " + message.getText());
- }
-
- // Step 11. Close the browser
- browser.close();
-
- // Step 12. Create a JMS Message Consumer
- MessageConsumer messageConsumer = session.createConsumer(queue);
-
- // Step 13. Start the Connection
- connection.start();
-
- // Step 14. Receive the 2 messages
- TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000);
- System.out.println("Received message: " + messageReceived.getText());
- messageReceived = (TextMessage) messageConsumer.receive(5000);
- System.out.println("Received message: " + messageReceived.getText());
- }
- 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/6b17d966/examples/broker-features/standard/browser/src/main/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/browser/src/main/resources/jndi.properties b/examples/broker-features/standard/browser/src/main/resources/jndi.properties
deleted file mode 100644
index 93537c4..0000000
--- a/examples/broker-features/standard/browser/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
-queue.queue/exampleQueue=exampleQueue
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/client-kickoff/pom.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/client-kickoff/pom.xml b/examples/broker-features/standard/client-kickoff/pom.xml
deleted file mode 100644
index 6ffb19a..0000000
--- a/examples/broker-features/standard/client-kickoff/pom.xml
+++ /dev/null
@@ -1,112 +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.broker</groupId>
- <artifactId>jms-examples</artifactId>
- <version>1.0.1-SNAPSHOT</version>
- </parent>
-
- <artifactId>client-kickoff</artifactId>
- <packaging>jar</packaging>
- <name>ActiveMQ Artemis JMS Kick Off 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>
-
- <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>
- <!-- options used for JMX on the example -->
- <javaOptions>-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=3000 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false
- </javaOptions>
- </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.ClientKickoffExample</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.broker</groupId>
- <artifactId>client-kickoff</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/client-kickoff/readme.html
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/client-kickoff/readme.html b/examples/broker-features/standard/client-kickoff/readme.html
deleted file mode 100644
index 8400e6a..0000000
--- a/examples/broker-features/standard/client-kickoff/readme.html
+++ /dev/null
@@ -1,54 +0,0 @@
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<html>
- <head>
- <title>ActiveMQ Artemis Client Kickoff Example</title>
- <link rel="stylesheet" type="text/css" href="../../../common/common.css" />
- <link rel="stylesheet" type="text/css" href="../../../common/prettify.css" />
- <script type="text/javascript" src="../../../common/prettify.js"></script>
- </head>
- <body onload="prettyPrint()">
- <h1>Client Kickoff 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 how to kick off a client connected to ActiveMQ
- using <a href="http://java.sun.com/javase/technologies/core/mntr-mgmt/javamanagement/">JMX</a></p>
-
- <p>The example will connect to ActiveMQ Artemis. Using JMX, we will list the remote addresses connected to the
- server and close the corresponding connections. The client will be kicked off from ActiveMQ Artemis receiving
- an exception that its JMS connection was interrupted.</p>
-
- <h2>Example configuration</h2>
-
- <p>ActiveMQ Artemis exposes its managed resources by default on the platform MBeanServer.</p>
- <p>To access this MBeanServer remotely, the Java Virtual machine must be started with system properties:
- <pre class="prettyprint">
- <code>-Dcom.sun.management.jmxremote
- -Dcom.sun.management.jmxremote.port=3000
- -Dcom.sun.management.jmxremote.ssl=false
- -Dcom.sun.management.jmxremote.authenticate=false</code>
- </pre>
- <p>These properties are explained in the Java 5 <a href="http://java.sun.com/j2se/1.5.0/docs/guide/management/agent.html#remote">Management guide</a>
- (please note that for this example, we will disable user authentication for simplicity).</p>
- <p>With these properties, ActiveMQ Artemis server will be manageable remotely using standard JMX URL on port <code>3000</code>.</p>
- </p>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/client-kickoff/src/main/java/org/apache/activemq/artemis/jms/example/ClientKickoffExample.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/client-kickoff/src/main/java/org/apache/activemq/artemis/jms/example/ClientKickoffExample.java b/examples/broker-features/standard/client-kickoff/src/main/java/org/apache/activemq/artemis/jms/example/ClientKickoffExample.java
deleted file mode 100644
index 14e9f37..0000000
--- a/examples/broker-features/standard/client-kickoff/src/main/java/org/apache/activemq/artemis/jms/example/ClientKickoffExample.java
+++ /dev/null
@@ -1,106 +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.ExceptionListener;
-import javax.jms.JMSException;
-import javax.jms.QueueConnection;
-import javax.jms.QueueConnectionFactory;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerInvocationHandler;
-import javax.management.ObjectName;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXServiceURL;
-import javax.naming.InitialContext;
-import java.util.HashMap;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl;
-import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
-
-/**
- * An example that shows how to kick off a client connected to ActiveMQ Artemis by using JMX.
- */
-public class ClientKickoffExample {
-
- private static final String JMX_URL = "service:jmx:rmi:///jndi/rmi://localhost:3000/jmxrmi";
-
- public static void main(final String[] args) throws Exception {
- QueueConnection 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 Connection Factory
- QueueConnectionFactory cf = (QueueConnectionFactory) initialContext.lookup("ConnectionFactory");
-
- // Step 3.Create a JMS Connection
- connection = cf.createQueueConnection();
-
- // Step 4. Set an exception listener on the connection to be notified after a problem occurred
- final AtomicReference<JMSException> exception = new AtomicReference<JMSException>();
- connection.setExceptionListener(new ExceptionListener() {
- @Override
- public void onException(final JMSException e) {
- exception.set(e);
- }
- });
-
- // Step 5. We start the connection
- connection.start();
-
- // Step 6. Create an ActiveMQServerControlMBean proxy to manage the server
- ObjectName on = ObjectNameBuilder.DEFAULT.getActiveMQServerObjectName();
- JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(JMX_URL), new HashMap<String, String>());
- MBeanServerConnection mbsc = connector.getMBeanServerConnection();
- ActiveMQServerControl serverControl = MBeanServerInvocationHandler.newProxyInstance(mbsc, on, ActiveMQServerControl.class, false);
-
- // Step 7. List the remote address connected to the server
- System.out.println("List of remote addresses connected to the server:");
- System.out.println("----------------------------------");
- String[] remoteAddresses = serverControl.listRemoteAddresses();
- for (String remoteAddress : remoteAddresses) {
- System.out.println(remoteAddress);
- }
- System.out.println("----------------------------------");
-
- // Step 8. Close the connections for the 1st remote address and kickoff the client
- serverControl.closeConnectionsForAddress(remoteAddresses[0]);
-
- // Sleep a little bit so that the stack trace from the server won't be
- // mingled with the JMSException received on the ExceptionListener
- Thread.sleep(1000);
-
- // Step 9. Display the exception received by the connection's ExceptionListener
- System.err.println("\nException received from the server:");
- System.err.println("----------------------------------");
- exception.get().printStackTrace();
- System.err.println("----------------------------------");
- }
- finally {
- // Step 10. Be sure to close the resources!
- if (initialContext != null) {
- initialContext.close();
- }
- if (connection != null) {
- connection.close();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/client-kickoff/src/main/resources/activemq/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/client-kickoff/src/main/resources/activemq/server0/broker.xml b/examples/broker-features/standard/client-kickoff/src/main/resources/activemq/server0/broker.xml
deleted file mode 100644
index 3b5a465..0000000
--- a/examples/broker-features/standard/client-kickoff/src/main/resources/activemq/server0/broker.xml
+++ /dev/null
@@ -1,47 +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">
-
- </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>
-
- <!-- true to expose ActiveMQ Artemis resources through JMX -->
- <jmx-management-enabled>true</jmx-management-enabled>
-
- <!-- Acceptors -->
- <acceptors>
- <acceptor name="netty">tcp://localhost:61616</acceptor>
- </acceptors>
- </core>
-
-</configuration>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/client-kickoff/src/main/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/client-kickoff/src/main/resources/jndi.properties b/examples/broker-features/standard/client-kickoff/src/main/resources/jndi.properties
deleted file mode 100644
index 5cbe72c..0000000
--- a/examples/broker-features/standard/client-kickoff/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/6b17d966/examples/broker-features/standard/consumer-rate-limit/pom.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/consumer-rate-limit/pom.xml b/examples/broker-features/standard/consumer-rate-limit/pom.xml
deleted file mode 100644
index c1db582..0000000
--- a/examples/broker-features/standard/consumer-rate-limit/pom.xml
+++ /dev/null
@@ -1,109 +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.broker</groupId>
- <artifactId>jms-examples</artifactId>
- <version>1.0.1-SNAPSHOT</version>
- </parent>
-
- <artifactId>consumer-rate-limit</artifactId>
- <packaging>jar</packaging>
- <name>ActiveMQ Artemis JMS Consumer Rate Limit 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>
-
- <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.ConsumerRateLimitExample</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.broker</groupId>
- <artifactId>consumer-rate-limit</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/consumer-rate-limit/readme.html
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/consumer-rate-limit/readme.html b/examples/broker-features/standard/consumer-rate-limit/readme.html
deleted file mode 100644
index 415de00..0000000
--- a/examples/broker-features/standard/consumer-rate-limit/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 Message Consumer Rate Limiting</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 Message Consumer Rate Limiting</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>With ActiveMQ Artemis you can specify a maximum consume rate at which a JMS MessageConsumer will consume messages.
- This can be specified when creating or configuring the connection factory. See <code>jndi.properties</code>.</p>
- <p>If this value is specified then ActiveMQ Artemis will ensure that messages are never consumed at a rate higher than
- the specified rate. This is a form of consumer <i>throttling</i>.</p>
- <h2>Example step-by-step</h2>
- <p>In this example we specify a <code>consumer-max-rate</code> of <code>10</code> messages per second in the <code>jndi.properties</code>
- file when configuring the connection factory:</p>
- <pre class="prettyprint">
- <code>
-connectionFactory.ConnectionFactory=tcp://localhost:61616?consumerMaxRate=10
- </code>
- </pre>
- <p>We then simply consume as many messages as we can in 10 seconds and note how many messages are actually consumed.</p>
- <p>We note that the number of messages consumed per second never exceeds the specified value of <code>10</code> messages per second.</p>
-
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/consumer-rate-limit/src/main/java/org/apache/activemq/artemis/jms/example/ConsumerRateLimitExample.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/consumer-rate-limit/src/main/java/org/apache/activemq/artemis/jms/example/ConsumerRateLimitExample.java b/examples/broker-features/standard/consumer-rate-limit/src/main/java/org/apache/activemq/artemis/jms/example/ConsumerRateLimitExample.java
deleted file mode 100644
index fb98c76..0000000
--- a/examples/broker-features/standard/consumer-rate-limit/src/main/java/org/apache/activemq/artemis/jms/example/ConsumerRateLimitExample.java
+++ /dev/null
@@ -1,115 +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.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.naming.InitialContext;
-
-/**
- * This example demonstrates how a message consumer can be limited to consumer messages at a maximum rate
- * specified in messages per sec.
- */
-public class ConsumerRateLimitExample {
-
- 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. Perfom a lookup on the queue
- Queue queue = (Queue) initialContext.lookup("queue/exampleQueue");
-
- // 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 JMS Message Producer
- MessageProducer producer = session.createProducer(queue);
-
- // Step 7. Create a JMS Message Consumer
-
- MessageConsumer consumer = session.createConsumer(queue);
-
- // Step 8. Start the connection
-
- connection.start();
-
- // Step 9. Send a bunch of messages
-
- final int numMessages = 150;
-
- for (int i = 0; i < numMessages; i++) {
- TextMessage message = session.createTextMessage("This is text message: " + i);
-
- producer.send(message);
- }
-
- System.out.println("Sent messages");
-
- System.out.println("Will now try and consume as many as we can in 10 seconds ...");
-
- // Step 10. Consume as many messages as we can in 10 seconds
-
- final long duration = 10000;
-
- int i = 0;
-
- long start = System.currentTimeMillis();
-
- while (System.currentTimeMillis() - start <= duration) {
- TextMessage message = (TextMessage) consumer.receive(2000);
-
- if (message == null) {
- throw new RuntimeException("Message was null");
- }
-
- i++;
- }
-
- long end = System.currentTimeMillis();
-
- double rate = 1000 * (double) i / (end - start);
-
- System.out.println("We consumed " + i + " messages in " + (end - start) + " milliseconds");
-
- System.out.println("Actual consume rate was " + rate + " messages per second");
- }
- finally {
- // Step 9. 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/6b17d966/examples/broker-features/standard/consumer-rate-limit/src/main/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/consumer-rate-limit/src/main/resources/jndi.properties b/examples/broker-features/standard/consumer-rate-limit/src/main/resources/jndi.properties
deleted file mode 100644
index 74729fe..0000000
--- a/examples/broker-features/standard/consumer-rate-limit/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?consumerMaxRate=10
-queue.queue/exampleQueue=exampleQueue
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/dead-letter/pom.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/dead-letter/pom.xml b/examples/broker-features/standard/dead-letter/pom.xml
deleted file mode 100644
index 9c5c5a0..0000000
--- a/examples/broker-features/standard/dead-letter/pom.xml
+++ /dev/null
@@ -1,110 +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.broker</groupId>
- <artifactId>jms-examples</artifactId>
- <version>1.0.1-SNAPSHOT</version>
- </parent>
-
- <artifactId>dead-letter</artifactId>
- <packaging>jar</packaging>
- <name>ActiveMQ Artemis JMS Dead Letter 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>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>create</id>
- <goals>
- <goal>create</goal>
- </goals>
- <configuration>
- <configuration>${basedir}/target/classes/activemq/server0</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.DeadLetterExample</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.broker</groupId>
- <artifactId>dead-letter</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/dead-letter/readme.html
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/dead-letter/readme.html b/examples/broker-features/standard/dead-letter/readme.html
deleted file mode 100644
index e293936..0000000
--- a/examples/broker-features/standard/dead-letter/readme.html
+++ /dev/null
@@ -1,66 +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 Dead Letter 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>Dead Letter 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 define and deal with dead letter messages.</p>
- <p>Messages can be delivered unsuccessfully (e.g. if the transacted session used to consume them is rolled back).
- Such a message goes back to the JMS destination ready to be redelivered.
- However, this means it is possible for a message to be delivered again and again without any success and remain in the destination, clogging the system.</p>
- <p>To prevent this, messaging systems define dead letter messages: after a specified unsuccessful delivery attempts, the message is removed from the destination
- and instead routed to a <em>dead letter address</em> where they can be consumed for further investigation.
- <p>
- The example will show how to configure ActiveMQ Artemis to route a message to a dead letter address after 3 unsuccessful delivery attempts.<br />
- The example will send 1 message to a queue. We will deliver the message 3 times and rollback the session every time.<br />
- On the 4th attempt, there won't be any message to consume: it will have been moved to a <em>dead letter address</em>.<br />
- We will then consume this dead letter message.
- </p>
- <h2>Example setup</h2>
- <p><em>Dead letter addresses</em> and <em>maximum delivery attempts</em> are defined in the configuration file <a href="src/main/resources/activemq/server0/broker.xml">broker.xml</a>:</p>
- <pre class="prettyprint">
- <code><address-setting match="jms.queue.exampleQueue">
- <dead-letter-address>jms.queue.deadLetterQueue</dead-letter-address>
- <max-delivery-attempts>3</max-delivery-attempts>
- </address-setting>
- </code>
- </pre>
- <p>This configuration will moved dead letter messages from <code>exampleQueue</code> to the <code>deadLetterQueue</code>.</p>
- <p>ActiveMQ Artemis allows to specify either a <code>Queue</code> by prefixing the <code>dead-letter-address</code> with <code>jms.queue.</code>
- or a <code>Topic</code> by prefixing with <code>jms.topic.</code>.<br />
- In this example, we will use a <code>Queue</code> to hold the dead letter messages.</p>
- <p>The maximum attempts of delivery is <code>3</code>. Once this figure is reached, a message is considered a dead letter message and is moved to
- the <code>deadLetterQueue</code>.
- <p>Since we want to consume messages from this deadLetterQueue, we also need to add a JNDI binding to perform a lookup.
- This is configured in <a href="src/main/resources/activemq/server0/activemq-jms.xml">activemq-jms.xml</a></p>
- <pre class="prettyprint">
- <code><queue name="deadLetterQueue">
- <entry name="/queue/deadLetterQueue"/>
- </queue></code>
- </pre>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/dead-letter/src/main/java/org/apache/activemq/artemis/jms/example/DeadLetterExample.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/dead-letter/src/main/java/org/apache/activemq/artemis/jms/example/DeadLetterExample.java b/examples/broker-features/standard/dead-letter/src/main/java/org/apache/activemq/artemis/jms/example/DeadLetterExample.java
deleted file mode 100644
index db28568..0000000
--- a/examples/broker-features/standard/dead-letter/src/main/java/org/apache/activemq/artemis/jms/example/DeadLetterExample.java
+++ /dev/null
@@ -1,136 +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.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.naming.InitialContext;
-
-/**
- * An example showing how messages are moved to dead letter destination when they are unsuccessfully delivered multiple times
- */
-public class DeadLetterExample {
-
- 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. Perfom a lookup on the queue
- Queue queue = (Queue) initialContext.lookup("queue/exampleQueue");
-
- // 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 * transacted* JMS Session
- Session session = connection.createSession(true, 0);
-
- // Step 6. Create a JMS Message Producer
- MessageProducer producer = session.createProducer(queue);
-
- // Step 7. Create a Text Message
- TextMessage message = session.createTextMessage("this is a text message");
-
- // Step 8. Send the Message
- producer.send(message);
- System.out.println("Sent message to " + queue.getQueueName() + ": " + message.getText());
-
- // Step 9. Commit the session to effectively send the message
- session.commit();
-
- // Step 10. Create a JMS Message Consumer for the queue
- MessageConsumer messageConsumer = session.createConsumer(queue);
-
- // Step 11. Start the Connection
- connection.start();
-
- // Step 12. We receive a message...
- TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000);
- System.out.println("1st delivery from " + queue.getQueueName() + ": " + messageReceived.getText());
-
- // Step 13. ... but we roll back the session. the message returns to the queue ready to be redelivered
- session.rollback();
-
- // Step 14. We receive a message and roll back the session a second time
- messageReceived = (TextMessage) messageConsumer.receive(5000);
- System.out.println("2nd delivery from " + queue.getQueueName() + ": " + messageReceived.getText());
- session.rollback();
-
- // Step 15. We receive a message and roll back the session a third time
- messageReceived = (TextMessage) messageConsumer.receive(5000);
- System.out.println("3rd delivery from " + queue.getQueueName() + ": " + messageReceived.getText());
- session.rollback();
-
- // The message has been delivered unsuccessfully 3 times -> it is moved to the dead letter queue.
-
- // Step 16. The 4th time, call will timeout after 5000ms and messageReceived will be null
- messageReceived = (TextMessage) messageConsumer.receive(5000);
- System.out.println("4th delivery from " + queue.getQueueName() + ": " + messageReceived);
-
- // We will now consume the message from the dead letter queue
-
- // Step 17. Perform a lookup on the dead letter queue
- Queue deadLetterQueue = (Queue) initialContext.lookup("queue/deadLetterQueue");
-
- // Step 18. Create a JMS Message Consumer for the dead letter queue
- MessageConsumer deadLetterConsumer = session.createConsumer(deadLetterQueue);
-
- // Step 19. Receive the message from the dead letter queue
- messageReceived = (TextMessage) deadLetterConsumer.receive(5000);
-
- // Step 20. The message sent to the queue was moved to the dead letter queue after 3 unsuccessful deliveries
- System.out.println("Received message from " + deadLetterQueue.getQueueName() +
- ": " +
- messageReceived.getText());
-
- // The message received from the dead letter queue has the same content than the undelivered message but its
- // JMS headers
- // differ (from JMS point of view, it's not the same message).
- // ActiveMQ Artemis defines additional properties for messages received from the dead letter queue
-
- System.out.println();
- // Step 21. the messageReceived's destination is now the dead letter queue.
- System.out.println("Destination of the message: " + ((Queue) messageReceived.getJMSDestination()).getQueueName());
-
- // Step 22. the *origin* destination is stored in the _AMQ_ORIG_ADDRESS property
- System.out.println("*Origin destination* of the message: " + messageReceived.getStringProperty("_AMQ_ORIG_ADDRESS"));
-
- // Step 23. This time, we commit the session, the delivery from the dead letter queue is successful!
- session.commit();
- }
- finally {
- // Step 24. Be sure to close our JMS resources!
- if (initialContext != null) {
- initialContext.close();
- }
- if (connection != null) {
- connection.close();
- }
- }
- }
-}