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/12 05:47:29 UTC
[35/52] [abbrv] [partial] activemq-artemis git commit: This commit
has improvements on the examples including:
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/broker-features/standard/paging/src/main/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/paging/src/main/resources/jndi.properties b/examples/broker-features/standard/paging/src/main/resources/jndi.properties
new file mode 100644
index 0000000..6f70010
--- /dev/null
+++ b/examples/broker-features/standard/paging/src/main/resources/jndi.properties
@@ -0,0 +1,21 @@
+# 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
+queue.queue/pagingQueue=pagingQueue
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/broker-features/standard/pom.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/pom.xml b/examples/broker-features/standard/pom.xml
new file mode 100644
index 0000000..106462b
--- /dev/null
+++ b/examples/broker-features/standard/pom.xml
@@ -0,0 +1,171 @@
+<?xml version='1.0'?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.activemq.examples.clustered</groupId>
+ <artifactId>broker-features</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.activemq.examples.broker</groupId>
+ <artifactId>jms-examples</artifactId>
+ <packaging>pom</packaging>
+ <name>ActiveMQ Artemis Standard Examples</name>
+
+ <properties>
+ <udp-address>231.7.7.7</udp-address>
+ <activemq.basedir>${project.basedir}/../../..</activemq.basedir>
+ </properties>
+
+ <profiles>
+ <profile>
+ <id>release</id>
+ <modules>
+ <module>bridge</module>
+ <module>browser</module>
+ <module>client-kickoff</module>
+ <module>consumer-rate-limit</module>
+ <module>dead-letter</module>
+ <module>delayed-redelivery</module>
+ <module>divert</module>
+ <module>durable-subscription</module>
+ <module>embedded</module>
+ <module>embedded-simple</module>
+ <module>expiry</module>
+ <module>http-transport</module>
+ <module>interceptor</module>
+ <module>instantiate-connection-factory</module>
+ <module>jms-auto-closeable</module>
+ <module>jms-bridge</module>
+ <module>jms-completion-listener</module>
+ <module>jms-context</module>
+ <module>jms-shared-consumer</module>
+ <module>jmx</module>
+ <module>large-message</module>
+ <module>last-value-queue</module>
+ <module>management</module>
+ <module>management-notifications</module>
+ <module>message-counters</module>
+ <module>message-group</module>
+ <module>message-group2</module>
+ <module>message-priority</module>
+ <module>no-consumer-buffering</module>
+ <module>paging</module>
+ <module>pre-acknowledge</module>
+ <module>producer-rate-limit</module>
+ <module>queue</module>
+ <module>queue-requestor</module>
+ <module>queue-selector</module>
+ <module>reattach-node</module>
+ <module>rest</module>
+ <module>request-reply</module>
+ <module>scheduled-message</module>
+ <module>security</module>
+ <module>send-acknowledgements</module>
+ <module>spring-integration</module>
+ <module>ssl-enabled</module>
+ <module>static-selector</module>
+ <module>temp-queue</module>
+ <module>topic</module>
+ <module>topic-hierarchies</module>
+ <module>topic-selector-example1</module>
+ <module>topic-selector-example2</module>
+ <module>transactional</module>
+ <module>xa-heuristic</module>
+ <module>xa-receive</module>
+ <module>xa-send</module>
+ </modules>
+ </profile>
+ <profile>
+ <id>examples</id>
+ <modules>
+ <module>bridge</module>
+ <module>browser</module>
+ <module>client-kickoff</module>
+ <module>consumer-rate-limit</module>
+ <module>dead-letter</module>
+ <module>delayed-redelivery</module>
+ <module>divert</module>
+ <module>durable-subscription</module>
+ <module>embedded</module>
+ <module>embedded-simple</module>
+ <module>expiry</module>
+ <module>http-transport</module>
+ <module>interceptor</module>
+ <module>jms-auto-closeable</module>
+ <module>instantiate-connection-factory</module>
+ <module>jms-bridge</module>
+ <module>jms-completion-listener</module>
+ <module>jms-context</module>
+ <module>jms-shared-consumer</module>
+ <module>jmx</module>
+ <module>large-message</module>
+ <module>last-value-queue</module>
+ <module>management</module>
+ <module>management-notifications</module>
+ <module>message-counters</module>
+ <module>message-group</module>
+ <module>message-group2</module>
+ <module>message-priority</module>
+ <module>no-consumer-buffering</module>
+ <module>paging</module>
+ <module>pre-acknowledge</module>
+ <module>producer-rate-limit</module>
+ <module>queue</module>
+ <module>queue-requestor</module>
+ <module>queue-selector</module>
+ <module>reattach-node</module>
+
+ <module>request-reply</module>
+ <module>rest</module>
+ <module>scheduled-message</module>
+ <module>security</module>
+ <module>send-acknowledgements</module>
+ <module>spring-integration</module>
+
+ <!-- ARTEMIS-197 FIX ME
+ this one could be the case of leaving it out for good
+ as it may require to be run manually
+ <module>ssl-enabled</module> -->
+
+ <module>static-selector</module>
+
+ <!--this needs to be run standalone as it needs manual intervention-->
+ <!--<module>stop-server-failover</module>-->
+
+ <module>temp-queue</module>
+ <module>topic</module>
+ <module>topic-hierarchies</module>
+ <module>topic-selector-example1</module>
+ <module>topic-selector-example2</module>
+ <module>transactional</module>
+ <module>xa-heuristic</module>
+ <module>xa-receive</module>
+ <module>xa-send</module>
+ </modules>
+ </profile>
+
+ </profiles>
+
+
+</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/broker-features/standard/pre-acknowledge/pom.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/pre-acknowledge/pom.xml b/examples/broker-features/standard/pre-acknowledge/pom.xml
new file mode 100644
index 0000000..c5da1a5
--- /dev/null
+++ b/examples/broker-features/standard/pre-acknowledge/pom.xml
@@ -0,0 +1,109 @@
+<?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>pre-acknowledge</artifactId>
+ <packaging>jar</packaging>
+ <name>ActiveMQ Artemis JMS Pre Acknowledge 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.PreacknowledgeExample</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>pre-acknowledge</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/broker-features/standard/pre-acknowledge/readme.html
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/pre-acknowledge/readme.html b/examples/broker-features/standard/pre-acknowledge/readme.html
new file mode 100644
index 0000000..235c278
--- /dev/null
+++ b/examples/broker-features/standard/pre-acknowledge/readme.html
@@ -0,0 +1,154 @@
+<!--
+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 Pre-Acknowledge 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 Pre-Acknowledge 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>Standard JMS supports three acknowledgement modes: AUTO_ACKNOWLEDGE, CLIENT_ACKNOWLEDGE, and
+ DUPS_OK_ACKNOWLEDGE. For a full description on these modes please consult the JMS specification, or any
+ JMS tutorial.</p>
+ <p>All of these standard modes involve sending acknowledgements from the client to the server. However
+ in some cases, you really don't mind losing messages in event of failure, so it would make sense
+ to acknowledge the message on the server <b>before</b> delivering it to the client.</p>
+ <p>By acknowledging the message before sending to the client, you can avoid extra network traffic and CPU
+ work done in sending acknowledgements from client to server.</p>
+ <p>The down-side of acknowledging on the server before delivery, is that if the system crashes after acknowledging
+ the message, but before the message has been received by the client, then, on recovery, that message
+ will be lost. This makes pre-acknowledgement not appropriate for all use cases, but it is very useful for some
+ use-cases when you can cope with such loss of messages<p>
+ <p>An example of a use-case where it might be a good idea to use pre-acknowledge, is for stock price update
+ messages. With these messages it might be ok to lose a message in event of crash, since the next price
+ update message will arrive soon, overriding the previous price.</p>
+ <p>In order to use pre-acknowledge functionality with ActiveMQ Artemis the session has to be created with
+ a special, ActiveMQ Artemis specific acknowledgement mode, given by the value of
+ <code>ActiveMQJMSConstants.PRE_ACKNOWLEDGE</code>.
+ <h2>Example step-by-step</h2>
+
+ <ol>
+ <li>Create an initial context to perform the JNDI lookup.</li>
+ <pre class="prettyprint">
+ <code>
+ initialContext = getContext(0);
+ </code>
+ </pre>
+
+ <li>Perform the look-ups</li>
+ <pre class="prettyprint">
+ <code>
+ Queue queue = (Queue)initialContext.lookup("/queue/exampleQueue");
+
+ ConnectionFactory cf = (ConnectionFactory)initialContext.lookup("/ConnectionFactory");
+ </code>
+ </pre>
+
+ <li>Create a the JMS objects.</li>
+ <pre class="prettyprint">
+ <code>
+ connection = cf.createConnection();
+
+ Session session = connection.createSession(false, ActiveMQSession.PRE_ACKNOWLEDGE);
+
+ MessageProducer producer = session.createProducer(queue);
+
+ MessageConsumer messageConsumer = session.createConsumer(queue);
+ </code>
+ </pre>
+
+ <li>Create and send a message.</li>
+ <pre class="prettyprint">
+ <code>
+ TextMessage message1 = session.createTextMessage("This is a text message 1");
+
+ producer.send(message1);
+
+ System.out.println("Sent message: " + message1.getText());
+ </code>
+ </pre>
+
+ <li>Print out the message count of the queue. The queue contains one message as expected
+ delivery has not yet started on the queue.</li>
+ <pre class="prettyprint">
+ <code>
+ int count = getMessageCount(connection);
+
+ System.out.println("Queue message count is " + count);
+ </code>
+ </pre>
+
+ <li>Start the Connection, delivery will now start. Give a little time for delivery to occur.</li>
+ <pre class="prettyprint">
+ <code>
+ connection.start();
+
+ Thread.sleep(1000);
+ </code>
+ </pre>
+
+ <li>Print out the message count of the queue. It should now be zero, since the message has
+ already been acknowledged even before the consumer has received it.</li>
+ <pre class="prettyprint">
+ <code>
+ count = getMessageCount(connection);
+
+ System.out.println("Queue message count is now " + count);
+ </code>
+ </pre>
+
+ <li>Finally, receive the message.</li>
+ <pre class="prettyprint">
+ <code>
+ TextMessage messageReceived = (TextMessage)messageConsumer.receive(5000);
+
+ System.out.println("Received message: " + messageReceived.getText());
+ </code>
+ </pre>
+
+ <li>Be sure to close our resources!</li>
+ <pre class="prettyprint">
+ <code>
+ if (initialContext != null)
+ {
+ initialContext.close();
+ }
+ if (connection != null)
+ {
+ connection.close();
+ }
+ </code>
+ </pre>
+ </ol>
+
+ <h2>More information</h2>
+
+ <ul>
+ <li>User Manual's <a href="../../../docs/user-manual/en/html_single/index.html#pre-acknowledge">Pre-acknowledgement Mode chapter</a></li>
+ </ul>
+
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/broker-features/standard/pre-acknowledge/src/main/java/org/apache/activemq/artemis/jms/example/PreacknowledgeExample.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/pre-acknowledge/src/main/java/org/apache/activemq/artemis/jms/example/PreacknowledgeExample.java b/examples/broker-features/standard/pre-acknowledge/src/main/java/org/apache/activemq/artemis/jms/example/PreacknowledgeExample.java
new file mode 100644
index 0000000..834b54a
--- /dev/null
+++ b/examples/broker-features/standard/pre-acknowledge/src/main/java/org/apache/activemq/artemis/jms/example/PreacknowledgeExample.java
@@ -0,0 +1,126 @@
+/*
+ * 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.QueueConnection;
+import javax.jms.QueueRequestor;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
+import org.apache.activemq.artemis.api.jms.ActiveMQJMSConstants;
+import org.apache.activemq.artemis.api.jms.management.JMSManagementHelper;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
+
+/**
+ * This example demonstrates the use of ActiveMQ Artemis "pre-acknowledge" functionality where
+ * messages are acknowledged before they are delivered to the consumer.
+ *
+ * Please see the readme.html for more details.
+ */
+public class PreacknowledgeExample {
+
+ public static void main(final String[] args) throws Exception {
+ Connection connection = null;
+ try {
+
+ // Step 2. instantiate the queue object
+ Queue queue = ActiveMQJMSClient.createQueue("exampleQueue");
+
+ // new connection factory
+ ConnectionFactory cf = new ActiveMQConnectionFactory();
+
+ // Step 3. Create a the JMS objects
+ connection = cf.createConnection();
+
+ Session session = connection.createSession(false, ActiveMQJMSConstants.PRE_ACKNOWLEDGE);
+
+ MessageProducer producer = session.createProducer(queue);
+
+ MessageConsumer messageConsumer = session.createConsumer(queue);
+
+ // Step 4. Create and send a message
+ TextMessage message1 = session.createTextMessage("This is a text message 1");
+
+ producer.send(message1);
+
+ System.out.println("Sent message: " + message1.getText());
+
+ // Step 5. Print out the message count of the queue. The queue contains one message as expected
+ // delivery has not yet started on the queue
+ int count = getMessageCount(connection);
+
+ System.out.println("Queue message count is " + count);
+
+ // Step 6. Start the Connection, delivery will now start. Give a little time for delivery to occur.
+ connection.start();
+
+ Thread.sleep(1000);
+
+ // Step 7. Print out the message countof the queue. It should now be zero, since the message has
+ // already been acknowledged even before the consumer has received it.
+ count = getMessageCount(connection);
+
+ System.out.println("Queue message count is now " + count);
+
+ if (count != 0) {
+ throw new IllegalStateException("Queue message count is not 0.");
+ }
+
+ // Step 8. Finally, receive the message
+ TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000);
+
+ System.out.println("Received message: " + messageReceived.getText());
+ }
+ finally {
+ // Step 9. Be sure to close our resources!
+ if (connection != null) {
+ connection.close();
+ }
+ }
+ }
+
+ // To do this we send a management message to get the message count.
+ // In real life you wouldn't create a new session every time you send a management message
+ private static int getMessageCount(final Connection connection) throws Exception {
+ QueueSession session = ((QueueConnection) connection).createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ Queue managementQueue = ActiveMQJMSClient.createQueue("activemq.management");
+
+ QueueRequestor requestor = new QueueRequestor(session, managementQueue);
+
+ connection.start();
+
+ Message m = session.createMessage();
+
+ JMSManagementHelper.putAttribute(m, "jms.queue.exampleQueue", "messageCount");
+
+ Message response = requestor.request(m);
+
+ int messageCount = (Integer) JMSManagementHelper.getResult(response);
+
+ return messageCount;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/broker-features/standard/pre-acknowledge/src/main/resources/activemq/server0/artemis-roles.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/pre-acknowledge/src/main/resources/activemq/server0/artemis-roles.properties b/examples/broker-features/standard/pre-acknowledge/src/main/resources/activemq/server0/artemis-roles.properties
new file mode 100644
index 0000000..4e2d44c
--- /dev/null
+++ b/examples/broker-features/standard/pre-acknowledge/src/main/resources/activemq/server0/artemis-roles.properties
@@ -0,0 +1,17 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+guest=guest
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/broker-features/standard/pre-acknowledge/src/main/resources/activemq/server0/artemis-users.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/pre-acknowledge/src/main/resources/activemq/server0/artemis-users.properties b/examples/broker-features/standard/pre-acknowledge/src/main/resources/activemq/server0/artemis-users.properties
new file mode 100644
index 0000000..4e2d44c
--- /dev/null
+++ b/examples/broker-features/standard/pre-acknowledge/src/main/resources/activemq/server0/artemis-users.properties
@@ -0,0 +1,17 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+guest=guest
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/broker-features/standard/pre-acknowledge/src/main/resources/activemq/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/pre-acknowledge/src/main/resources/activemq/server0/broker.xml b/examples/broker-features/standard/pre-acknowledge/src/main/resources/activemq/server0/broker.xml
new file mode 100644
index 0000000..f29acbc
--- /dev/null
+++ b/examples/broker-features/standard/pre-acknowledge/src/main/resources/activemq/server0/broker.xml
@@ -0,0 +1,63 @@
+<?xml version='1.0'?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:activemq"
+ xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd">
+
+ <jms xmlns="urn:activemq:jms">
+ <!--the queue used by the example-->
+ <queue name="exampleQueue"/>
+ </jms>
+
+ <core xmlns="urn:activemq:core">
+
+ <bindings-directory>${data.dir}/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>
+
+ <!-- Acceptors -->
+ <acceptors>
+ <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor>
+ </acceptors>
+
+ <!-- Other config -->
+
+ <security-settings>
+ <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-setting match="jms.queue.activemq.management">
+ <permission type="manage" roles="guest"/>
+ </security-setting>
+ </security-settings>
+
+ </core>
+</configuration>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/broker-features/standard/pre-acknowledge/src/main/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/pre-acknowledge/src/main/resources/jndi.properties b/examples/broker-features/standard/pre-acknowledge/src/main/resources/jndi.properties
new file mode 100644
index 0000000..93537c4
--- /dev/null
+++ b/examples/broker-features/standard/pre-acknowledge/src/main/resources/jndi.properties
@@ -0,0 +1,20 @@
+# 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/21bf4406/examples/broker-features/standard/producer-rate-limit/pom.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/producer-rate-limit/pom.xml b/examples/broker-features/standard/producer-rate-limit/pom.xml
new file mode 100644
index 0000000..91b7603
--- /dev/null
+++ b/examples/broker-features/standard/producer-rate-limit/pom.xml
@@ -0,0 +1,109 @@
+<?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>producer-rate-limit</artifactId>
+ <packaging>jar</packaging>
+ <name>ActiveMQ Artemis JMS Producer 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.ProducerRateLimitExample</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>producer-rate-limit</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/broker-features/standard/producer-rate-limit/readme.html
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/producer-rate-limit/readme.html b/examples/broker-features/standard/producer-rate-limit/readme.html
new file mode 100644
index 0000000..7e10ca3
--- /dev/null
+++ b/examples/broker-features/standard/producer-rate-limit/readme.html
@@ -0,0 +1,176 @@
+<!--
+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 Producer 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 Producer 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 send rate at which a JMS MessageProducer will send messages.
+ This can be specified when creating or deploying the connection factory. See <code>activemq-jms.xml</code></p>
+ <p>If this value is specified then ActiveMQ Artemis will ensure that messages are never produced at a rate higher than
+ specified. This is a form of producer <i>throttling</i>.</p>
+ <h2>Example step-by-step</h2>
+ <p>In this example we specify a <code>producer-max-rate</code> of <code>50</code> messages per second in the <code>activemq-jms.xml</code>
+ file when deploying the connection factory:</p>
+ <pre class="prettyprint">
+ <code>
+ <connection-factory name="ConnectionFactory">
+ <connector-ref connector-name="netty-connector"/>
+ <entries>
+ <entry name="ConnectionFactory"/>
+ </entries>
+
+ <!-- We limit producers created on this connection factory to produce messages at a maximum rate
+ of 50 messages per sec -->
+ <producer-max-rate>50</producer-max-rate>
+
+ </connection-factory>
+ </code>
+ </pre>
+ <p>We then simply send as many messages as we can in 10 seconds and note how many messages are actually sent.</p>
+ <p>We note that the number of messages sent per second never exceeds the specified value of <code>50</code> messages per second.</p>
+
+ <ol>
+ <li>Create an initial context to perform the JNDI lookup.</li>
+ <pre class="prettyprint">
+ <code>initialContext = getContext(0);</code>
+ </pre>
+
+ <li>Perfom a lookup on the queue</li>
+ <pre class="prettyprint">
+ <code>Queue queue = (Queue)initialContext.lookup("/queue/exampleQueue");</code>
+ </pre>
+
+ <li>Perform a lookup on the Connection Factory</li>
+ <pre class="prettyprint">
+ <code>ConnectionFactory cf = (ConnectionFactory)initialContext.lookup("/ConnectionFactory");</code>
+ </pre>
+
+ <li>Create a JMS Connection</li>
+ <pre class="prettyprint">
+ <code>connection = cf.createConnection();</code>
+ </pre>
+
+ <li>Create a JMS Session</li>
+ <pre class="prettyprint">
+ <code>Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);</code>
+ </pre>
+
+ <li>Create a JMS Message Producer</li>
+ <pre class="prettyprint">
+ <code>MessageProducer producer = session.createProducer(queue);</code>
+ </pre>
+
+ <li>Send as many messages as we can in 10 seconds</li>
+ <pre class="prettyprint">
+ <code>
+ final long duration = 10000;
+
+ int i = 0;
+
+ long start = System.currentTimeMillis();
+
+ while (System.currentTimeMillis() - start <= duration)
+ {
+ TextMessage message = session.createTextMessage("This is text message: " + i++);
+
+ producer.send(message);
+ }
+
+ long end = System.currentTimeMillis();
+
+ double rate = 1000 * (double)i / (end - start);
+
+ System.out.println("We sent " + i + " messages in " + (end - start) + " milliseconds");
+
+ System.out.println("Actual send rate was " + rate + " messages per second");
+ </code>
+ </pre>
+
+ <li>We note that the sending rate doesn't exceed 50 messages per second. Here's some example output from a real
+ run</li>
+
+ <pre class="prettyprint">
+ <code>
+ [java] Will now send as many messages as we can in 10 seconds...
+ [java] We sent 500 messages in 10072 milliseconds
+ [java] Actual send rate was 49.64257347100874 messages per second
+ </code>
+ </pre>
+
+
+ <li>For good measure we consumer the messages we produced.</li>
+ <pre class="prettyprint">
+ <code>
+ MessageConsumer messageConsumer = session.createConsumer(queue);
+
+ connection.start();
+
+ System.out.println("Now consuming the messages...");
+
+ i = 0;
+ while (true)
+ {
+ TextMessage messageReceived = (TextMessage)messageConsumer.receive(5000);
+
+ if (messageReceived == null)
+ {
+ break;
+ }
+
+ i++;
+ }
+
+ System.out.println("Received " + i + " messages");
+
+ </code>
+ </pre>
+
+ <li>Be sure to close our resources!</li>
+
+ <pre class="prettyprint">
+ <code>
+ finally
+ {
+ if (initialContext != null)
+ {
+ initialContext.close();
+ }
+
+ if (connection != null)
+ {
+ connection.close();
+ }
+ }</code>
+ </pre>
+
+
+
+ </ol>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/broker-features/standard/producer-rate-limit/src/main/java/org/apache/activemq/artemis/jms/example/ProducerRateLimitExample.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/producer-rate-limit/src/main/java/org/apache/activemq/artemis/jms/example/ProducerRateLimitExample.java b/examples/broker-features/standard/producer-rate-limit/src/main/java/org/apache/activemq/artemis/jms/example/ProducerRateLimitExample.java
new file mode 100644
index 0000000..a7623bb
--- /dev/null
+++ b/examples/broker-features/standard/producer-rate-limit/src/main/java/org/apache/activemq/artemis/jms/example/ProducerRateLimitExample.java
@@ -0,0 +1,106 @@
+/*
+ * 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 org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
+
+/**
+ * This example demonstrates how a message producer can be limited to produce messages at a maximum rate
+ * specified in messages per sec.
+ */
+public class ProducerRateLimitExample {
+
+ public static void main(final String[] args) throws Exception {
+ Connection connection = null;
+ try {
+ // Step 2. Perfom a lookup on the queue
+ Queue queue = ActiveMQJMSClient.createQueue("exampleQueue");
+
+ // Step 3. Perform a lookup on the Connection Factory
+ ConnectionFactory cf = new ActiveMQConnectionFactory("tcp://localhost:61616?producerMaxRate=50");
+
+ // 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);
+
+ System.out.println("Will now send as many messages as we can in 10 seconds...");
+
+ // Step 7. Send 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 = session.createTextMessage("This is text message: " + i++);
+
+ producer.send(message);
+ }
+
+ long end = System.currentTimeMillis();
+
+ double rate = 1000 * (double) i / (end - start);
+
+ System.out.println("We sent " + i + " messages in " + (end - start) + " milliseconds");
+
+ System.out.println("Actual send rate was " + rate + " messages per second");
+
+ // Step 8. For good measure we consumer the messages we produced.
+
+ MessageConsumer messageConsumer = session.createConsumer(queue);
+
+ connection.start();
+
+ System.out.println("Now consuming the messages...");
+
+ i = 0;
+ while (true) {
+ TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000);
+
+ if (messageReceived == null) {
+ break;
+ }
+
+ i++;
+ }
+
+ System.out.println("Received " + i + " messages");
+ }
+ finally {
+ // Step 9. Be sure to close our resources!
+ if (connection != null) {
+ connection.close();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/broker-features/standard/producer-rate-limit/src/main/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/producer-rate-limit/src/main/resources/jndi.properties b/examples/broker-features/standard/producer-rate-limit/src/main/resources/jndi.properties
new file mode 100644
index 0000000..0e42b2a
--- /dev/null
+++ b/examples/broker-features/standard/producer-rate-limit/src/main/resources/jndi.properties
@@ -0,0 +1,20 @@
+# 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?producerMaxRate=50
+queue.queue/exampleQueue=exampleQueue
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/broker-features/standard/queue-requestor/pom.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/queue-requestor/pom.xml b/examples/broker-features/standard/queue-requestor/pom.xml
new file mode 100644
index 0000000..df59a6a
--- /dev/null
+++ b/examples/broker-features/standard/queue-requestor/pom.xml
@@ -0,0 +1,104 @@
+<?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>queue-requestor</artifactId>
+ <packaging>jar</packaging>
+ <name>ActiveMQ Artemis JMS Queue Requestor 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>
+ </execution>
+ <execution>
+ <id>start</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <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.QueueRequestorExample</clientClass>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stop</id>
+ <goals>
+ <goal>cli</goal>
+ </goals>
+ <configuration>
+ <args>
+ <param>stop</param>
+ </args>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.activemq.examples.broker</groupId>
+ <artifactId>queue-requestor</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/broker-features/standard/queue-requestor/readme.html
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/queue-requestor/readme.html b/examples/broker-features/standard/queue-requestor/readme.html
new file mode 100644
index 0000000..68a1c95
--- /dev/null
+++ b/examples/broker-features/standard/queue-requestor/readme.html
@@ -0,0 +1,46 @@
+<!--
+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 QueueRequestor 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 QueueRequestor 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 <a href="http://java.sun.com/javaee/5/docs/api/javax/jms/QueueRequestor.html">QueueRequestor</a> with ActiveMQ Artemis.</p>
+ <p>JMS is mainly used to send messages asynchronously so that the producer of a message is not waiting for the result of the message consumption.
+ However, there are cases where it is necessary to have a synchronous behavior: the code sending a message requires a reply for this message
+ before continuing its execution.<br />
+ A QueueRequestor facilitates this use case by providing a simple request/reply abstraction on top of JMS.</p>
+ <p>The example consists in two classes:</p>
+ <dl>
+ <dt><code>TextReverserService</code></dt>
+ <dd>A JMS MessageListener which consumes text messages and sends replies containing the reversed text</dd>
+ <dt><code>QueueRequestorExample</code></dt>
+ <dd>A JMS Client which uses a QueueRequestor to send text requests to a queue and receive replies with the reversed text in a synchronous fashion</dd>
+ </dl>
+ </body>
+</html>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/broker-features/standard/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/QueueRequestorExample.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/QueueRequestorExample.java b/examples/broker-features/standard/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/QueueRequestorExample.java
new file mode 100644
index 0000000..607d82f
--- /dev/null
+++ b/examples/broker-features/standard/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/QueueRequestorExample.java
@@ -0,0 +1,96 @@
+/*
+ * 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.JMSException;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueRequestor;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+
+/**
+ * A simple JMS example that shows how to use queues requestors.
+ */
+public class QueueRequestorExample {
+
+ 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. Perfom a lookup on the queue
+ Queue queue = (Queue) initialContext.lookup("queue/exampleQueue");
+
+ // Step 3. Look-up the JMS queue connection factory
+ QueueConnectionFactory cf = (QueueConnectionFactory) initialContext.lookup("ConnectionFactory");
+
+ // Step 4. Create a TextReverserService which consumes messages from the queue and sends message with reversed
+ // text
+ TextReverserService reverserService = new TextReverserService(cf, queue);
+
+ // Step 5. Create a JMS QueueConnection
+ connection = cf.createQueueConnection();
+
+ // Step 6. Start the connection
+ connection.start();
+
+ // Step 7. Create a JMS queue session with AUTO_ACKNOWLEDGE mode
+ QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ // Step 8. Create a JMS queue requestor to send requests to the queue
+ QueueRequestor queueRequestor = new QueueRequestor(session, queue);
+
+ // Step 9. Create a JMS message to send as a request
+ TextMessage request = session.createTextMessage("Hello, World!");
+
+ // Step 10. Use the requestor to send the request and wait to receive a reply
+ TextMessage reply = (TextMessage) queueRequestor.request(request);
+
+ // Step 11. The reply's text contains the reversed request's text
+ System.out.println("Send request: " + request.getText());
+ System.out.println("Received reply:" + reply.getText());
+
+ // Step.12 close the queue requestor
+ queueRequestor.close();
+
+ // Step 13. close the text reverser service
+ reverserService.close();
+ }
+ finally {
+ if (connection != null) {
+ try {
+ // Step 14. Be sure to close the JMS resources!
+ connection.close();
+ }
+ catch (JMSException e) {
+ e.printStackTrace();
+ }
+ }
+
+ if (initialContext != null) {
+ // Also the InitialContext
+ initialContext.close();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/broker-features/standard/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/TextReverserService.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/TextReverserService.java b/examples/broker-features/standard/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/TextReverserService.java
new file mode 100644
index 0000000..63fdad2
--- /dev/null
+++ b/examples/broker-features/standard/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/TextReverserService.java
@@ -0,0 +1,113 @@
+/*
+ * 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.Destination;
+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;
+
+/**
+ * A TextReverserService is a MessageListener which consume text messages from a destination
+ * and replies with text messages containing the reversed text.
+ * It sends replies to the destination specified by the JMS ReplyTo header of the consumed messages.
+ */
+public class TextReverserService implements MessageListener {
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private final Session session;
+
+ private final Connection connection;
+
+ // Static --------------------------------------------------------
+
+ private static String reverse(final String text) {
+ return new StringBuffer(text).reverse().toString();
+ }
+
+ // Constructors --------------------------------------------------
+
+ public TextReverserService(final ConnectionFactory cf, final Destination destination) throws JMSException {
+ // create a JMS connection
+ connection = cf.createConnection();
+ // create a JMS session
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ // create a JMS MessageConsumer to consume message from the destination
+ MessageConsumer consumer = session.createConsumer(destination);
+ // let TextReverter implement MessageListener to consume messages
+ consumer.setMessageListener(this);
+
+ // start the connection to start consuming messages
+ connection.start();
+ }
+
+ // MessageListener implementation --------------------------------
+
+ public void onMessage(final Message request) {
+ TextMessage textMessage = (TextMessage) request;
+ try {
+ // retrieve the request's text
+ String text = textMessage.getText();
+ // create a reply containing the reversed text
+ TextMessage reply = session.createTextMessage(TextReverserService.reverse(text));
+
+ // retrieve the destination to reply to
+ Destination replyTo = request.getJMSReplyTo();
+ // create a producer to send the reply
+ MessageProducer producer = session.createProducer(replyTo);
+ // send the reply
+ producer.send(reply);
+ // close the producer
+ producer.close();
+ }
+ catch (JMSException e) {
+ e.printStackTrace();
+ }
+ }
+
+ // Public --------------------------------------------------------
+
+ public void close() {
+ if (connection != null) {
+ try {
+ // be sure to close the JMS resources
+ connection.close();
+ }
+ catch (JMSException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/broker-features/standard/queue-requestor/src/main/resources/activemq/server0/artemis-roles.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/queue-requestor/src/main/resources/activemq/server0/artemis-roles.properties b/examples/broker-features/standard/queue-requestor/src/main/resources/activemq/server0/artemis-roles.properties
new file mode 100644
index 0000000..4e2d44c
--- /dev/null
+++ b/examples/broker-features/standard/queue-requestor/src/main/resources/activemq/server0/artemis-roles.properties
@@ -0,0 +1,17 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+guest=guest
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/broker-features/standard/queue-requestor/src/main/resources/activemq/server0/artemis-users.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/queue-requestor/src/main/resources/activemq/server0/artemis-users.properties b/examples/broker-features/standard/queue-requestor/src/main/resources/activemq/server0/artemis-users.properties
new file mode 100644
index 0000000..4e2d44c
--- /dev/null
+++ b/examples/broker-features/standard/queue-requestor/src/main/resources/activemq/server0/artemis-users.properties
@@ -0,0 +1,17 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+guest=guest
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/broker-features/standard/queue-requestor/src/main/resources/activemq/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/queue-requestor/src/main/resources/activemq/server0/broker.xml b/examples/broker-features/standard/queue-requestor/src/main/resources/activemq/server0/broker.xml
new file mode 100644
index 0000000..6c344c2
--- /dev/null
+++ b/examples/broker-features/standard/queue-requestor/src/main/resources/activemq/server0/broker.xml
@@ -0,0 +1,67 @@
+<?xml version='1.0'?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:activemq"
+ xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd">
+
+ <jms xmlns="urn:activemq:jms">
+ <!--the queue used by the example-->
+ <queue name="exampleQueue"/>
+ </jms>
+
+ <core xmlns="urn:activemq:core">
+
+ <bindings-directory>${data.dir}/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>
+
+ <!-- Acceptors -->
+ <acceptors>
+ <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor>
+ </acceptors>
+
+ <!-- Other config -->
+
+ <security-settings>
+ <!--security for example queues -->
+ <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 for JMS temporary queue -->
+ <security-setting match="jms.tempqueue.#">
+ <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/broker-features/standard/queue-requestor/src/main/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/queue-requestor/src/main/resources/jndi.properties b/examples/broker-features/standard/queue-requestor/src/main/resources/jndi.properties
new file mode 100644
index 0000000..93537c4
--- /dev/null
+++ b/examples/broker-features/standard/queue-requestor/src/main/resources/jndi.properties
@@ -0,0 +1,20 @@
+# 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/21bf4406/examples/broker-features/standard/queue-selector/pom.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/queue-selector/pom.xml b/examples/broker-features/standard/queue-selector/pom.xml
new file mode 100644
index 0000000..9da147c
--- /dev/null
+++ b/examples/broker-features/standard/queue-selector/pom.xml
@@ -0,0 +1,109 @@
+<?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>queue-selector</artifactId>
+ <packaging>jar</packaging>
+ <name>ActiveMQ Artemis JMS Queue Selector 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.QueueSelectorExample</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>queue-selector</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/broker-features/standard/queue-selector/readme.html
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/queue-selector/readme.html b/examples/broker-features/standard/queue-selector/readme.html
new file mode 100644
index 0000000..ef63063
--- /dev/null
+++ b/examples/broker-features/standard/queue-selector/readme.html
@@ -0,0 +1,52 @@
+<!--
+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 Queue Selector 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 Queue Selector 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 selectively consume messages using message selectors with queue consumers.</p>
+
+ <p>Message selectors are strings with special syntax that can be used in creating consumers. Message consumers
+ created with a message selector will only receive messages that match its selector. On message delivery, the JBoss Message
+ 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 queue. 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>
+
+ <p>Selectors can be used with both queue consumers and topic consumers. The difference is that with queue consumers,
+ a message is only delivered to one consumer on the queue, while topic consumers the message will be delivered to every
+ matching consumers. In this example, if the third consumer (anyConsumer) were the first consumer created, it will
+ consume the first message delivered, therefore there is no chance for the next consumer to get the message, even if it
+ matches the selector.</p>
+ </body>
+</html>