http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/proton-j/readme.html ---------------------------------------------------------------------- diff --git a/examples/jms/proton-j/readme.html b/examples/jms/proton-j/readme.html deleted file mode 100644 index fd77ffc..0000000 --- a/examples/jms/proton-j/readme.html +++ /dev/null @@ -1,95 +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 QPID java 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>Proton qpid java example</h1> - -<pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre> - - -<<p>ActiveMQ Artemis is a multi protocol broker. It will inspect the initial handshake of clients to determine what protocol to use.</p> -<p>All you need to do is to connect a client into activemq's configured port and you should be able connect.</p> -<p>To run this example simply run the command <literal>mvn verify -Pexample</literal>, execute the compile.sh script and start the executable called ./hello</p> - -<p>You don't need to do anything special to configure the ActiveMQ Artemis server to accept AMQP clients. </p> -<p>Just for the sake of documentation though we are setting the port of ActiveMQ Artemis on this example as 5672 which is the port qpid have by default. </p> -<p>This is totally optional and you don't need to follow this convention. You can use any port you chose including ActiveMQ's 61616 default port</p> - <pre class="prettyprint"> - <code> - <acceptor name="proton-acceptor">tcp://localhost:5672</acceptor> - </code> - </pre> -<h2>Example step-by-step</h2> -<ol> - <li> Create an amqp qpid 1.0 connection.</li> - <pre class="prettyprint"> - <code>connection= new Connection("localhost", 5672, null, null);</code> - </pre> - - <li>Create a session</li> - <pre class="prettyprint"> - <code>Session session = connection.createSession();</code> - </pre> - - <li>Create a sender</li> - <pre class="prettyprint"> - <code>Sender sender = session.createSender("testQueue");</code> - </pre> - - <li>send a simple message</li> - <pre class="prettyprint"> - <code>sender.send(new Message("I am an amqp message"));</code> - </pre> - - <li>create a moving receiver, this means the message will be removed from the queue</li> - <pre class="prettyprint"> - <code>Receiver rec = session.createMovingReceiver("testQueue");</code> - </pre> - - <li>set some credit so we can receive</li> - <pre class="prettyprint"> - <code>rec.setCredit(UnsignedInteger.valueOf(1), false);</code> - </pre> - - <li>receive the simple message</li> - <pre class="prettyprint"> - <code>Message m = rec.receive(5000); - System.out.println("message = " + m.getPayload());</code> - </pre> - - <li>acknowledge the message</li> - <pre class="prettyprint"> - <code>rec.acknowledge(m);</code> - </pre> - - <li>close the connection</li> - <pre class="prettyprint"> - <code>connection.close();</code> - </pre> -</ol> - -</body> -</html>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/proton-j/src/main/java/org/apache/activemq/artemis/jms/example/ProtonJExample.java ---------------------------------------------------------------------- diff --git a/examples/jms/proton-j/src/main/java/org/apache/activemq/artemis/jms/example/ProtonJExample.java b/examples/jms/proton-j/src/main/java/org/apache/activemq/artemis/jms/example/ProtonJExample.java deleted file mode 100644 index 85334b4..0000000 --- a/examples/jms/proton-j/src/main/java/org/apache/activemq/artemis/jms/example/ProtonJExample.java +++ /dev/null @@ -1,64 +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.qpid.amqp_1_0.client.Connection; -import org.apache.qpid.amqp_1_0.client.Message; -import org.apache.qpid.amqp_1_0.client.Receiver; -import org.apache.qpid.amqp_1_0.client.Sender; -import org.apache.qpid.amqp_1_0.client.Session; -import org.apache.qpid.amqp_1_0.type.UnsignedInteger; - -public class ProtonJExample { - - public static void main(String[] args) throws Exception { - Connection connection = null; - - try { - // Step 1. Create an amqp qpid 1.0 connection - connection = new Connection("localhost", 5672, null, null); - - // Step 2. Create a session - Session session = connection.createSession(); - - // Step 3. Create a sender - Sender sender = session.createSender("jms.queue.exampleQueue"); - - // Step 4. send a simple message - sender.send(new Message("I am an amqp message")); - - // Step 5. create a moving receiver, this means the message will be removed from the queue - Receiver rec = session.createMovingReceiver("jms.queue.exampleQueue"); - - // Step 6. set some credit so we can receive - rec.setCredit(UnsignedInteger.valueOf(1), false); - - // Step 7. receive the simple message - Message m = rec.receive(5000); - System.out.println("message = " + m.getPayload()); - - // Step 8. acknowledge the message - rec.acknowledge(m); - } - finally { - if (connection != null) { - // Step 9. close the connection - connection.close(); - } - } - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/proton-j/src/main/resources/activemq/server0/artemis-roles.properties ---------------------------------------------------------------------- diff --git a/examples/jms/proton-j/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/proton-j/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44c..0000000 --- a/examples/jms/proton-j/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/proton-j/src/main/resources/activemq/server0/artemis-users.properties ---------------------------------------------------------------------- diff --git a/examples/jms/proton-j/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/proton-j/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44c..0000000 --- a/examples/jms/proton-j/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/proton-j/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/jms/proton-j/src/main/resources/activemq/server0/broker.xml b/examples/jms/proton-j/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index f1df1c6..0000000 --- a/examples/jms/proton-j/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,68 +0,0 @@ -<?xml version='1.0'?> -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns="urn:activemq" - xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> - - <jms xmlns="urn:activemq:jms"> - <!--the queue used by the example--> - <queue name="exampleQueue"/> - </jms> - - <core xmlns="urn:activemq:core"> - - <bindings-directory>${data.dir}/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="proton-acceptor">tcp://localhost:5672</acceptor> - <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor> - </acceptors> - - <queues> - <queue name="testQueue"> - <address>testQueue</address> - </queue> - </queues> - - <!-- Other config --> - - <security-settings> - <!--security for example queue--> - <security-setting match="jms.queue.exampleQueue"> - <permission type="createDurableQueue" roles="guest"/> - <permission type="deleteDurableQueue" roles="guest"/> - <permission type="createNonDurableQueue" roles="guest"/> - <permission type="deleteNonDurableQueue" roles="guest"/> - <permission type="consume" roles="guest"/> - <permission type="send" roles="guest"/> - </security-setting> - </security-settings> - - </core> -</configuration> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/proton-ruby/pom.xml ---------------------------------------------------------------------- diff --git a/examples/jms/proton-ruby/pom.xml b/examples/jms/proton-ruby/pom.xml deleted file mode 100644 index 6a90b8d..0000000 --- a/examples/jms/proton-ruby/pom.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version='1.0'?> -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.activemq.examples.jms</groupId> - <artifactId>jms-examples</artifactId> - <version>1.0.1-SNAPSHOT</version> - </parent> - - <artifactId>proton-ruby</artifactId> - <packaging>jar</packaging> - <name>ActiveMQ Artemis Proton Ruby Example</name> - - <properties> - <activemq.basedir>${project.basedir}/../../..</activemq.basedir> - </properties> - - <build> - <plugins> - <plugin> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-maven-plugin</artifactId> - <executions> - <execution> - <id>create</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <instance>${basedir}/target/server0</instance> - <configuration>${basedir}/target/classes/activemq/server0</configuration> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.apache.activemq.examples.jms</groupId> - <artifactId>proton-ruby</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - </plugin> - </plugins> - </build> - -</project> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/proton-ruby/readme.html ---------------------------------------------------------------------- diff --git a/examples/jms/proton-ruby/readme.html b/examples/jms/proton-ruby/readme.html deleted file mode 100644 index 95c15b0..0000000 --- a/examples/jms/proton-ruby/readme.html +++ /dev/null @@ -1,51 +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 Proton Ruby 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>Proton Ruby Example</h1> - - <p>ActiveMQ Artemis can be configured to accept requests from any AMQP client that supports the 1.0 version of the protocol. - This example shows a simply proton ruby client that sends and receives messages</p> - <p>To run the example you will need the following packages installed, alsa-lib.i686 libXv.i686 libXScrnSaver.i686 qt.i686 qt-x11.i686 qtwebkit-2.2.2-2.fc18.i686, gcc, ruby</p> - <p>On fedora you can install these via the <literal>yum install alsa-lib.i686 libXv.i686 libXScrnSaver.i686 qt.i686 qt-x11.i686 qtwebkit-2.2.2-2.fc18.i686, gcc, ruby</literal> - command</p> - <p>you will also need the qpid-proton libraries installed, again <literal>yum install qpid-proton</literal></p> - <p>lastly you wull have to create the gems <literal>gem install qpid_proton</literal></p> - - <p>To configure ActiveMQ Artemis to accept AMQP client connections you need to add an Acceptor like so:</p> - <pre class="prettyprint"> - <code> - <acceptor name="proton-acceptor">tcp://localhost:5672?protocols=AMQP</acceptor> - </code> - </pre> - <h2>Example step-by-step</h2> - <p>Firstly create the server by running the command <literal>mvn verify</literal></p> - <p>Start the server manually under ./target/server1/bin by calling ./artemis run</p> - <p>Then in a separate window you can run the send ruby script by running the command <literal>ruby src/main/scripts/send.rb</literal></p> - <p>You can then receive the message via the receive ruby script by running <literal>ruby src/main/scripts/receive.rb</literal></p> - - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/proton-ruby/src/main/resources/activemq/server0/artemis-roles.properties ---------------------------------------------------------------------- diff --git a/examples/jms/proton-ruby/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/proton-ruby/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44c..0000000 --- a/examples/jms/proton-ruby/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/proton-ruby/src/main/resources/activemq/server0/artemis-users.properties ---------------------------------------------------------------------- diff --git a/examples/jms/proton-ruby/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/proton-ruby/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44c..0000000 --- a/examples/jms/proton-ruby/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/proton-ruby/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/jms/proton-ruby/src/main/resources/activemq/server0/broker.xml b/examples/jms/proton-ruby/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 81e0b07..0000000 --- a/examples/jms/proton-ruby/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,65 +0,0 @@ -<?xml version='1.0'?> -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns="urn:activemq" - xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> - - <jms xmlns="urn:activemq:jms"> - <!--the queue used by the example--> - <queue name="exampleQueue"/> - </jms> - - <core xmlns="urn:activemq:core"> - - <bindings-directory>${data.dir}/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="proton-acceptor">tcp://localhost:5672?protocols=AMQP;</acceptor> - </acceptors> - - <queues> - <queue name="testQueue"> - <address>testQueue</address> - </queue> - </queues> - <!-- Other config --> - - <security-settings> - <!--security for example queue--> - <security-setting match="#"> - <permission type="createDurableQueue" roles="guest"/> - <permission type="deleteDurableQueue" roles="guest"/> - <permission type="createNonDurableQueue" roles="guest"/> - <permission type="deleteNonDurableQueue" roles="guest"/> - <permission type="consume" roles="guest"/> - <permission type="send" roles="guest"/> - </security-setting> - </security-settings> - - </core> -</configuration> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/proton-ruby/src/main/scripts/receive.rb ---------------------------------------------------------------------- diff --git a/examples/jms/proton-ruby/src/main/scripts/receive.rb b/examples/jms/proton-ruby/src/main/scripts/receive.rb deleted file mode 100755 index 93228ff..0000000 --- a/examples/jms/proton-ruby/src/main/scripts/receive.rb +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env ruby -# 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. - -require 'qpid_proton' - -messenger = Qpid::Proton::Messenger.new() -messenger.incoming_window = 10 -messenger.timeout = 10000 - -begin - messenger.start -rescue ProtonError => error - puts "ERROR: #{error.message}" - puts error.backtrace.join("\n") - exit -end - - begin - messenger.subscribe("127.0.0.1:5672/testQueue") - rescue Qpid::Proton::ProtonError => error - puts "ERROR: #{error.message}" - exit - end - -msg = Qpid::Proton::Message.new - - begin - messenger.receive(1) - rescue Qpid::Proton::ProtonError => error - puts "ERROR: #{error.message}" - exit - end - - while messenger.incoming.nonzero? - begin - messenger.get(msg) - # for 0.5: - # messenger.accept() - - # for 0.4: - #messenger.accept(messenger.incoming_tracker, 0)#1 would mean cumulative - - # optional and the same in both versions (messenger will - # settle itself when tracker passes out the window) - # messenger.settle(messenger.incoming_tracker) - - - rescue Qpid::Proton::Error => error - puts "ERROR: #{error.message}" - exit - end - - puts "Address: #{msg.address}" - puts "Subject: #{msg.subject}" - puts "Content: #{msg.body}" - puts "Message ID: #{msg.id}" - end - -messenger.stop - http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/proton-ruby/src/main/scripts/send.rb ---------------------------------------------------------------------- diff --git a/examples/jms/proton-ruby/src/main/scripts/send.rb b/examples/jms/proton-ruby/src/main/scripts/send.rb deleted file mode 100755 index 1287280..0000000 --- a/examples/jms/proton-ruby/src/main/scripts/send.rb +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env ruby -# 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. - -require 'qpid_proton' - -address = "127.0.0.1:5672/testQueue" - -messenger = Qpid::Proton::Messenger.new -messenger.start - -msg = Qpid::Proton::Message.new -msg.address = address -msg.subject = "The time is #{Time.new}" -msg.body = "Hello world!" -msg.correlation_id = "554545" - -begin - messenger.put(msg) -rescue Qpid::Proton::ProtonError => error - puts "ERROR: #{error.message}" - exit -end - -begin - messenger.send -rescue Qpid::Proton::ProtonError => error - puts "ERROR: #{error.message}" - puts error.backtrace.join("\n") - exit -end - -puts "SENT: " + msg.body - -messenger.stop http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/queue-message-redistribution/pom.xml ---------------------------------------------------------------------- diff --git a/examples/jms/queue-message-redistribution/pom.xml b/examples/jms/queue-message-redistribution/pom.xml deleted file mode 100644 index bee7116..0000000 --- a/examples/jms/queue-message-redistribution/pom.xml +++ /dev/null @@ -1,164 +0,0 @@ -<?xml version='1.0'?> -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.activemq.examples.jms</groupId> - <artifactId>jms-examples</artifactId> - <version>1.0.1-SNAPSHOT</version> - </parent> - - <artifactId>queue-message-redistribution</artifactId> - <packaging>jar</packaging> - <name>ActiveMQ Artemis JMS Queue Message Redistribution Example</name> - - <properties> - <activemq.basedir>${project.basedir}/../../..</activemq.basedir> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-jms-client</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - - <profiles> - <profile> - <!-- specify -PnoServer if you don't want to start the server --> - <id>noServer</id> - <properties> - <noServer>true</noServer> - </properties> - </profile> - </profiles> - <build> - <plugins> - <plugin> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-maven-plugin</artifactId> - <executions> - <execution> - <id>create0</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <instance>${basedir}/target/server0</instance> - <configuration>${basedir}/target/classes/activemq/server0</configuration> - </configuration> - </execution> - <execution> - <id>create1</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <instance>${basedir}/target/server1</instance> - <configuration>${basedir}/target/classes/activemq/server1</configuration> - </configuration> - </execution> - <execution> - <id>start0</id> - <goals> - <goal>cli</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <spawn>true</spawn> - <location>${basedir}/target/server0</location> - <testURI>tcp://localhost:61616</testURI> - <args> - <param>run</param> - </args> - <name>server0</name> - </configuration> - </execution> - <execution> - <id>start1</id> - <goals> - <goal>cli</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <spawn>true</spawn> - <location>${basedir}/target/server1</location> - <testURI>tcp://localhost:61617</testURI> - <args> - <param>run</param> - </args> - <name>server1</name> - </configuration> - </execution> - <execution> - <id>runClient</id> - <goals> - <goal>runClient</goal> - </goals> - <configuration> - <clientClass>org.apache.activemq.artemis.jms.example.QueueMessageRedistributionExample - </clientClass> - </configuration> - </execution> - <execution> - <id>stop0</id> - <goals> - <goal>cli</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <location>${basedir}/target/server0</location> - <args> - <param>stop</param> - </args> - </configuration> - </execution> - <execution> - <id>stop1</id> - <goals> - <goal>cli</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <location>${basedir}/target/server1</location> - <args> - <param>stop</param> - </args> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.apache.activemq.examples.jms</groupId> - <artifactId>queue-message-redistribution</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - </plugin> - </plugins> - </build> - -</project> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/queue-message-redistribution/readme.html ---------------------------------------------------------------------- diff --git a/examples/jms/queue-message-redistribution/readme.html b/examples/jms/queue-message-redistribution/readme.html deleted file mode 100644 index b5c6cf6..0000000 --- a/examples/jms/queue-message-redistribution/readme.html +++ /dev/null @@ -1,61 +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 Message Redistribution 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>Message Redistribution 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 message redistribution between queues with the same name deployed in different - nodes of a cluster.</p> - <p>As demontrated in the clustered queue example, if queues with the same name are deployed on different nodes of - a cluster, ActiveMQ Artemis can be configured to load balance messages between the nodes on the server side.</p> - <p>However, if the consumer(s) on a particular node are closed, then messages in the queue at that node can - appear to be stranded, since they have no local consumers.</p> - <p>If this is undesirable, ActiveMQ Artemis can be configured to <b>redistribute</b> messages from the node - with no consumers, to nodes where there are consumers. If the consumers have JMS selectors set on them, then they - will only be redistributed to nodes with consumers whose selectors match.</p> - <p>By default, message redistribution is disabled, but can be enabled by specifying some AddressSettings configuration - in either <code>activemq-queues.xml</code> or <code>broker.xml</code></p> - <p>Setting <code>redistribution-delay</code> to <code>0</code> will cause redistribution to occur immediately - once there are no more matching consumers on a particular queue instance. Setting it to a positive value > 0 specifies - a delay in milliseconds before attempting to redistribute. The delay is useful in the case that another consumer is - likely to be created on the queue, to avoid unnecessary redistribution.</p> - <p>Here's the relevant snippet from the <code>activemq-queues.xml</code> configuration, which tells the server - to use a redistribution delay of <code>0</code> on any jms queues, i.e. any queues whose name starts with - <code>jms.</code></p> - <pre class="prettyprint"> - <code> - <address-setting match="jms.#"> - <redistribution-delay>0</redistribution-delay> - </address-setting> - </code> - </pre> - <p>For more information on ActiveMQ Artemis load balancing, and clustering in general, please see the clustering - section of the user manual.</p> - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/queue-message-redistribution/src/main/java/org/apache/activemq/artemis/jms/example/QueueMessageRedistributionExample.java ---------------------------------------------------------------------- diff --git a/examples/jms/queue-message-redistribution/src/main/java/org/apache/activemq/artemis/jms/example/QueueMessageRedistributionExample.java b/examples/jms/queue-message-redistribution/src/main/java/org/apache/activemq/artemis/jms/example/QueueMessageRedistributionExample.java deleted file mode 100644 index d04fee0..0000000 --- a/examples/jms/queue-message-redistribution/src/main/java/org/apache/activemq/artemis/jms/example/QueueMessageRedistributionExample.java +++ /dev/null @@ -1,147 +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; -import java.util.Hashtable; - -import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; -import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; - -/** - * This example demonstrates a queue with the same name deployed on two nodes of a cluster. - * Messages are initially round robin'd between both nodes of the cluster. - * The consumer on one of the nodes is then closed, and we demonstrate that the "stranded" messages - * are redistributed to the other node which has a consumer so they can be consumed. - */ -public class QueueMessageRedistributionExample { - - public static void main(final String[] args) throws Exception { - Connection connection0 = null; - - Connection connection1 = null; - - try { - // Step 2. Look-up the JMS Queue object from JNDI - Queue queue = ActiveMQJMSClient.createQueue("exampleQueue"); - - // Step 3. Look-up a JMS Connection Factory object from JNDI on server 0 - ConnectionFactory cf0 = new ActiveMQConnectionFactory("tcp://localhost:61616"); - - // Step 5. Look-up a JMS Connection Factory object from JNDI on server 1 - ConnectionFactory cf1 = new ActiveMQConnectionFactory("tcp://localhost:61617"); - - // Step 6. We create a JMS Connection connection0 which is a connection to server 0 - connection0 = cf0.createConnection(); - - // Step 7. We create a JMS Connection connection1 which is a connection to server 1 - connection1 = cf1.createConnection(); - - // Step 8. We create a JMS Session on server 0, note the session is CLIENT_ACKNOWLEDGE - Session session0 = connection0.createSession(false, Session.CLIENT_ACKNOWLEDGE); - - // Step 9. We create a JMS Session on server 1, note the session is CLIENT_ACKNOWLEDGE - Session session1 = connection1.createSession(false, Session.CLIENT_ACKNOWLEDGE); - - // Step 10. We start the connections to ensure delivery occurs on them - connection0.start(); - - connection1.start(); - - // Step 11. We create JMS MessageConsumer objects on server 0 and server 1 - MessageConsumer consumer0 = session0.createConsumer(queue); - - MessageConsumer consumer1 = session1.createConsumer(queue); - - Thread.sleep(1000); - - // Step 12. We create a JMS MessageProducer object on server 0 - MessageProducer producer = session0.createProducer(queue); - - // Step 13. We send some messages to server 0 - - final int numMessages = 10; - - for (int i = 0; i < numMessages; i++) { - TextMessage message = session0.createTextMessage("This is text message " + i); - - producer.send(message); - - System.out.println("Sent message: " + message.getText()); - } - - // Step 14. We now consume those messages on *both* server 0 and server 1. - // We note the messages have been distributed between servers in a round robin fashion - // JMS Queues implement point-to-point message where each message is only ever consumed by a - // maximum of one consumer - - TextMessage message0 = null; - - TextMessage message1 = null; - - for (int i = 0; i < numMessages; i += 2) { - message0 = (TextMessage) consumer0.receive(5000); - - System.out.println("Got message: " + message0.getText() + " from node 0"); - - message1 = (TextMessage) consumer1.receive(5000); - - System.out.println("Got message: " + message1.getText() + " from node 1"); - } - - // Step 15. We acknowledge the messages consumed on node 0. The sessions are CLIENT_ACKNOWLEDGE so - // messages will not get acknowledged until they are explicitly acknowledged. - // Note that we *do not* acknowledge the message consumed on node 1 yet. - message0.acknowledge(); - - // Step 16. We now close the session and consumer on node 1. (Closing the session automatically closes the - // consumer) - session1.close(); - - // Step 17. Since there is no more consumer on node 1, the messages on node 1 are now stranded (no local - // consumers) - // so ActiveMQ Artemis will redistribute them to node 0 so they can be consumed. - - for (int i = 0; i < numMessages; i += 2) { - message0 = (TextMessage) consumer0.receive(5000); - - System.out.println("Got message: " + message0.getText() + " from node 0"); - } - - // Step 18. We ack the messages. - message0.acknowledge(); - } - finally { - // Step 18. Be sure to close our resources! - - if (connection0 != null) { - connection0.close(); - } - - if (connection1 != null) { - connection1.close(); - } - } - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/queue-message-redistribution/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/jms/queue-message-redistribution/src/main/resources/activemq/server0/broker.xml b/examples/jms/queue-message-redistribution/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 70ff4d4..0000000 --- a/examples/jms/queue-message-redistribution/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,106 +0,0 @@ -<?xml version='1.0'?> -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns="urn:activemq" - xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> - - <jms xmlns="urn:activemq:jms"> - <!--the queue used by the example--> - <queue name="exampleQueue"/> - </jms> - - <core xmlns="urn:activemq:core"> - - <bindings-directory>./data/bindings</bindings-directory> - - <journal-directory>./data/journal</journal-directory> - - <large-messages-directory>./data/largemessages</large-messages-directory> - - <paging-directory>./data/paging</paging-directory> - - <!-- Connectors --> - <connectors> - <connector name="netty-connector">tcp://localhost:61616</connector> - </connectors> - - <!-- Acceptors --> - <acceptors> - <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor> - </acceptors> - - <!-- Clustering configuration --> - <broadcast-groups> - <broadcast-group name="my-broadcast-group"> - <group-address>${udp-address:231.7.7.7}</group-address> - <group-port>9876</group-port> - <broadcast-period>100</broadcast-period> - <connector-ref>netty-connector</connector-ref> - </broadcast-group> - </broadcast-groups> - - <discovery-groups> - <discovery-group name="my-discovery-group"> - <group-address>${udp-address:231.7.7.7}</group-address> - <group-port>9876</group-port> - <refresh-timeout>10000</refresh-timeout> - </discovery-group> - </discovery-groups> - - <cluster-connections> - <cluster-connection name="my-cluster"> - <address>jms</address> - <connector-ref>netty-connector</connector-ref> - <retry-interval>500</retry-interval> - <use-duplicate-detection>true</use-duplicate-detection> - <message-load-balancing>ON_DEMAND</message-load-balancing> - <max-hops>1</max-hops> - <discovery-group-ref discovery-group-name="my-discovery-group"/> - </cluster-connection> - </cluster-connections> - - <!-- Other config --> - - <security-settings> - <!--security for example queue--> - <security-setting match="jms.queue.exampleQueue"> - <permission type="createDurableQueue" roles="guest"/> - <permission type="deleteDurableQueue" roles="guest"/> - <permission type="createNonDurableQueue" roles="guest"/> - <permission type="deleteNonDurableQueue" roles="guest"/> - <permission type="consume" roles="guest"/> - <permission type="send" roles="guest"/> - </security-setting> - </security-settings> - - <address-settings> - <!-- We set a redistribution delay of zero on all jms queues and topic subscriptions - Default redistribution delay as -1 which means "disable redistribution" - Setting it to a value > 0 means how long to wait before redistributing, if a consumer is closed - then another one quickly recreated you might want to set it thus, to avoid unnecessary - redistribution --> - <address-setting match="jms.#"> - <redistribution-delay>0</redistribution-delay> - </address-setting> - </address-settings> - - </core> -</configuration> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/queue-message-redistribution/src/main/resources/activemq/server1/broker.xml ---------------------------------------------------------------------- diff --git a/examples/jms/queue-message-redistribution/src/main/resources/activemq/server1/broker.xml b/examples/jms/queue-message-redistribution/src/main/resources/activemq/server1/broker.xml deleted file mode 100644 index 6fc6f32..0000000 --- a/examples/jms/queue-message-redistribution/src/main/resources/activemq/server1/broker.xml +++ /dev/null @@ -1,107 +0,0 @@ -<?xml version='1.0'?> -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns="urn:activemq" - xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> - - <jms xmlns="urn:activemq:jms"> - <!--the queue used by the example--> - <queue name="exampleQueue"/> - </jms> - - <core xmlns="urn:activemq:core"> - - <bindings-directory>./data/bindings</bindings-directory> - - <journal-directory>./data/journal</journal-directory> - - <large-messages-directory>./data/largemessages</large-messages-directory> - - <paging-directory>./data/paging</paging-directory> - - <!-- Connectors --> - - <connectors> - <connector name="netty-connector">tcp://localhost:61617</connector> - </connectors> - - <!-- Acceptors --> - <acceptors> - <acceptor name="netty-acceptor">tcp://localhost:61617</acceptor> - </acceptors> - - <!-- Clustering configuration --> - <broadcast-groups> - <broadcast-group name="my-broadcast-group"> - <group-address>${udp-address:231.7.7.7}</group-address> - <group-port>9876</group-port> - <broadcast-period>100</broadcast-period> - <connector-ref>netty-connector</connector-ref> - </broadcast-group> - </broadcast-groups> - - <discovery-groups> - <discovery-group name="my-discovery-group"> - <group-address>${udp-address:231.7.7.7}</group-address> - <group-port>9876</group-port> - <refresh-timeout>10000</refresh-timeout> - </discovery-group> - </discovery-groups> - - <cluster-connections> - <cluster-connection name="my-cluster"> - <address>jms</address> - <connector-ref>netty-connector</connector-ref> - <retry-interval>500</retry-interval> - <use-duplicate-detection>true</use-duplicate-detection> - <message-load-balancing>ON_DEMAND</message-load-balancing> - <max-hops>1</max-hops> - <discovery-group-ref discovery-group-name="my-discovery-group"/> - </cluster-connection> - </cluster-connections> - - <!-- Other config --> - - <security-settings> - <!--security for example queue--> - <security-setting match="jms.queue.exampleQueue"> - <permission type="createDurableQueue" roles="guest"/> - <permission type="deleteDurableQueue" roles="guest"/> - <permission type="createNonDurableQueue" roles="guest"/> - <permission type="deleteNonDurableQueue" roles="guest"/> - <permission type="consume" roles="guest"/> - <permission type="send" roles="guest"/> - </security-setting> - </security-settings> - - <address-settings> - <!-- We set a redistribution delay of zero on all jms queues and topic subscriptions - Default redistribution delay as -1 which means "disable redistribution" - Setting it to a value > 0 means how long to wait before redistributing, if a consumer is closed - then another one quickly recreated you might want to set it thus, to avoid unnecessary - redistribution --> - <address-setting match="jms.#"> - <redistribution-delay>0</redistribution-delay> - </address-setting> - </address-settings> - - </core> -</configuration> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/queue-requestor/pom.xml ---------------------------------------------------------------------- diff --git a/examples/jms/queue-requestor/pom.xml b/examples/jms/queue-requestor/pom.xml deleted file mode 100644 index 35c380e..0000000 --- a/examples/jms/queue-requestor/pom.xml +++ /dev/null @@ -1,113 +0,0 @@ -<?xml version='1.0'?> -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.activemq.examples.jms</groupId> - <artifactId>jms-examples</artifactId> - <version>1.0.1-SNAPSHOT</version> - </parent> - - <artifactId>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> - - <profiles> - <profile> - <!-- specify -PnoServer if you don't want to start the server --> - <id>noServer</id> - <properties> - <noServer>true</noServer> - </properties> - </profile> - </profiles> - <build> - <plugins> - <plugin> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-maven-plugin</artifactId> - <executions> - <execution> - <id>create</id> - <goals> - <goal>create</goal> - </goals> - </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.jms</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/jms/queue-requestor/readme.html ---------------------------------------------------------------------- diff --git a/examples/jms/queue-requestor/readme.html b/examples/jms/queue-requestor/readme.html deleted file mode 100644 index af11c9c..0000000 --- a/examples/jms/queue-requestor/readme.html +++ /dev/null @@ -1,46 +0,0 @@ -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<html> - <head> - <title>ActiveMQ Artemis JMS 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/jms/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/QueueRequestorExample.java ---------------------------------------------------------------------- diff --git a/examples/jms/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/QueueRequestorExample.java b/examples/jms/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/QueueRequestorExample.java deleted file mode 100644 index 607d82f..0000000 --- a/examples/jms/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/QueueRequestorExample.java +++ /dev/null @@ -1,96 +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.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/jms/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/TextReverserService.java ---------------------------------------------------------------------- diff --git a/examples/jms/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/TextReverserService.java b/examples/jms/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/TextReverserService.java deleted file mode 100644 index 63fdad2..0000000 --- a/examples/jms/queue-requestor/src/main/java/org/apache/activemq/artemis/jms/example/TextReverserService.java +++ /dev/null @@ -1,113 +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.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/jms/queue-requestor/src/main/resources/activemq/server0/artemis-roles.properties ---------------------------------------------------------------------- diff --git a/examples/jms/queue-requestor/src/main/resources/activemq/server0/artemis-roles.properties b/examples/jms/queue-requestor/src/main/resources/activemq/server0/artemis-roles.properties deleted file mode 100644 index 4e2d44c..0000000 --- a/examples/jms/queue-requestor/src/main/resources/activemq/server0/artemis-roles.properties +++ /dev/null @@ -1,17 +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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/queue-requestor/src/main/resources/activemq/server0/artemis-users.properties ---------------------------------------------------------------------- diff --git a/examples/jms/queue-requestor/src/main/resources/activemq/server0/artemis-users.properties b/examples/jms/queue-requestor/src/main/resources/activemq/server0/artemis-users.properties deleted file mode 100644 index 4e2d44c..0000000 --- a/examples/jms/queue-requestor/src/main/resources/activemq/server0/artemis-users.properties +++ /dev/null @@ -1,17 +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. -## --------------------------------------------------------------------------- -guest=guest \ No newline at end of file http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/queue-requestor/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/jms/queue-requestor/src/main/resources/activemq/server0/broker.xml b/examples/jms/queue-requestor/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 6c344c2..0000000 --- a/examples/jms/queue-requestor/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version='1.0'?> -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns="urn:activemq" - xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd"> - - <jms xmlns="urn:activemq:jms"> - <!--the queue used by the example--> - <queue name="exampleQueue"/> - </jms> - - <core xmlns="urn:activemq:core"> - - <bindings-directory>${data.dir}/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/jms/queue-requestor/src/main/resources/jndi.properties ---------------------------------------------------------------------- diff --git a/examples/jms/queue-requestor/src/main/resources/jndi.properties b/examples/jms/queue-requestor/src/main/resources/jndi.properties deleted file mode 100644 index 93537c4..0000000 --- a/examples/jms/queue-requestor/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/21bf4406/examples/jms/queue-selector/pom.xml ---------------------------------------------------------------------- diff --git a/examples/jms/queue-selector/pom.xml b/examples/jms/queue-selector/pom.xml deleted file mode 100644 index dca3246..0000000 --- a/examples/jms/queue-selector/pom.xml +++ /dev/null @@ -1,118 +0,0 @@ -<?xml version='1.0'?> -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.activemq.examples.jms</groupId> - <artifactId>jms-examples</artifactId> - <version>1.0.1-SNAPSHOT</version> - </parent> - - <artifactId>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> - - <profiles> - <profile> - <!-- specify -PnoServer if you don't want to start the server --> - <id>noServer</id> - <properties> - <noServer>true</noServer> - </properties> - </profile> - </profiles> - <build> - <plugins> - <plugin> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-maven-plugin</artifactId> - <executions> - <execution> - <id>create</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - </configuration> - </execution> - <execution> - <id>start</id> - <goals> - <goal>cli</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <spawn>true</spawn> - <testURI>tcp://localhost:61616</testURI> - <args> - <param>run</param> - </args> - </configuration> - </execution> - <execution> - <id>runClient</id> - <goals> - <goal>runClient</goal> - </goals> - <configuration> - <clientClass>org.apache.activemq.artemis.jms.example.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.jms</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/jms/queue-selector/readme.html ---------------------------------------------------------------------- diff --git a/examples/jms/queue-selector/readme.html b/examples/jms/queue-selector/readme.html deleted file mode 100644 index edb3f7b..0000000 --- a/examples/jms/queue-selector/readme.html +++ /dev/null @@ -1,52 +0,0 @@ -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<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>
