You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2015/08/13 06:13:54 UTC
[36/48] activemq-artemis git commit: renaming broker-features ->
features on examples
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/interceptor/readme.html
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/interceptor/readme.html b/examples/broker-features/standard/interceptor/readme.html
deleted file mode 100644
index 42b1e18..0000000
--- a/examples/broker-features/standard/interceptor/readme.html
+++ /dev/null
@@ -1,72 +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 Interceptor 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 Interceptor 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 implement and configure a simple incoming, server-side interceptor with ActiveMQ Artemis.</p>
-
- <p>ActiveMQ Artemis allows an application to use an interceptor to hook into the messaging system. All that needs to do is to implement the
- Interceptor interface, as defined below: </p>
- <pre class="prettyprint">
- <code>
- public interface Interceptor
- {
- boolean intercept(Packet packet, RemotingConnection connection) throws ActiveMQException;
- }
- </code>
- </pre>
- <p>Once you have your own interceptor class, add it to the broker.xml, as follows:</p>
- <pre class="prettyprint">
- <code>
- <configuration>
- ...
- <remoting-incoming-interceptors>
- <class-name>org.apache.activemq.artemis.jms.example.SimpleInterceptor</class-name>
- </remoting-incoming-interceptors>
- ...
- </configuration>
- </code>
- </pre>
-
- <p>With interceptor, you can handle various events in message processing. In this example, a simple interceptor, SimpleInterceptor, is implemented and configured.
- When the example is running, the interceptor will print out each events that are passed in the interceptor. And it will add a string property to the message being
- delivered. You can see that after the message is received, there will be a new string property appears in the received message.</p>
-
- <p>With our interceptor we always return <code>true</code> from the <code>intercept</code> method. If we were
- to return <code>false</code> that signifies that no more interceptors are to run or the target
- is not to be called. Return <code>false</code> to abort processing of the packet.</p>
- </body>
-</html>
-
-
-
-
-
-
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/interceptor/src/main/java/org/apache/activemq/artemis/jms/example/InterceptorExample.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/interceptor/src/main/java/org/apache/activemq/artemis/jms/example/InterceptorExample.java b/examples/broker-features/standard/interceptor/src/main/java/org/apache/activemq/artemis/jms/example/InterceptorExample.java
deleted file mode 100644
index b78875f..0000000
--- a/examples/broker-features/standard/interceptor/src/main/java/org/apache/activemq/artemis/jms/example/InterceptorExample.java
+++ /dev/null
@@ -1,88 +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;
-
-/**
- * A simple JMS example that shows how to implement and use interceptors with ActiveMQ Artemis.
- */
-public class InterceptorExample {
-
- public static void main(final String[] args) throws Exception {
- Connection connection = null;
- InitialContext initialContext = null;
- try {
- // Step 1. Create an initial context to perform the JNDI lookup.
- initialContext = new InitialContext();
-
- // Step 2. Perform a lookup on the queue
- Queue queue = (Queue) initialContext.lookup("queue/exampleQueue");
-
- // Step 3. Perform a lookup on the Connection Factory
- ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("ConnectionFactory");
-
- // Step 4.Create a JMS Connection
- connection = cf.createConnection();
-
- // Step 5. Create a JMS Session
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- // Step 6. Create a JMS Message Producer
- MessageProducer producer = session.createProducer(queue);
-
- // Step 7. Create a Text Message
- TextMessage message = session.createTextMessage("This is a text message");
-
- System.out.println("Sending message [" + message.getText() +
- "] with String property: " +
- message.getStringProperty("newproperty"));
-
- // Step 8. Send the Message
- producer.send(message);
-
- // Step 9. Create a JMS Message Consumer
- MessageConsumer messageConsumer = session.createConsumer(queue);
-
- // Step 10. Start the Connection
- connection.start();
-
- // Step 11. Receive the message
- TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000);
-
- System.out.println("Received message [" + messageReceived.getText() +
- "] with String property: " +
- messageReceived.getStringProperty("newproperty"));
- }
- finally {
- // Step 12. Be sure to close our JMS resources!
- if (initialContext != null) {
- initialContext.close();
- }
- if (connection != null) {
- connection.close();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/interceptor/src/main/java/org/apache/activemq/artemis/jms/example/SimpleInterceptor.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/interceptor/src/main/java/org/apache/activemq/artemis/jms/example/SimpleInterceptor.java b/examples/broker-features/standard/interceptor/src/main/java/org/apache/activemq/artemis/jms/example/SimpleInterceptor.java
deleted file mode 100644
index 6836930..0000000
--- a/examples/broker-features/standard/interceptor/src/main/java/org/apache/activemq/artemis/jms/example/SimpleInterceptor.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.jms.example;
-
-import org.apache.activemq.artemis.api.core.ActiveMQException;
-import org.apache.activemq.artemis.api.core.Interceptor;
-import org.apache.activemq.artemis.api.core.Message;
-import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.core.protocol.core.Packet;
-import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionSendMessage;
-import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
-
-/**
- * A simple Interceptor implementation
- */
-public class SimpleInterceptor implements Interceptor {
-
- public boolean intercept(final Packet packet, final RemotingConnection connection) throws ActiveMQException {
- System.out.println("SimpleInterceptor gets called!");
- System.out.println("Packet: " + packet.getClass().getName());
- System.out.println("RemotingConnection: " + connection.getRemoteAddress());
-
- if (packet instanceof SessionSendMessage) {
- SessionSendMessage realPacket = (SessionSendMessage) packet;
- Message msg = realPacket.getMessage();
- msg.putStringProperty(new SimpleString("newproperty"), new SimpleString("Hello from interceptor!"));
- }
- // We return true which means "call next interceptor" (if there is one) or target.
- // If we returned false, it means "abort call" - no more interceptors would be called and neither would
- // the target
- return true;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/interceptor/src/main/resources/activemq/server0/artemis-roles.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/interceptor/src/main/resources/activemq/server0/artemis-roles.properties b/examples/broker-features/standard/interceptor/src/main/resources/activemq/server0/artemis-roles.properties
deleted file mode 100644
index 4e2d44c..0000000
--- a/examples/broker-features/standard/interceptor/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/6b17d966/examples/broker-features/standard/interceptor/src/main/resources/activemq/server0/artemis-users.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/interceptor/src/main/resources/activemq/server0/artemis-users.properties b/examples/broker-features/standard/interceptor/src/main/resources/activemq/server0/artemis-users.properties
deleted file mode 100644
index 4e2d44c..0000000
--- a/examples/broker-features/standard/interceptor/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/6b17d966/examples/broker-features/standard/interceptor/src/main/resources/activemq/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/interceptor/src/main/resources/activemq/server0/broker.xml b/examples/broker-features/standard/interceptor/src/main/resources/activemq/server0/broker.xml
deleted file mode 100644
index fc82158..0000000
--- a/examples/broker-features/standard/interceptor/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:../data}/bindings</bindings-directory>
-
- <journal-directory>${data.dir:../data}/journal</journal-directory>
-
- <large-messages-directory>${data.dir:../data}/largemessages</large-messages-directory>
-
- <paging-directory>${data.dir:../data}/paging</paging-directory>
-
-
- <remoting-incoming-interceptors>
- <class-name>org.apache.activemq.artemis.jms.example.SimpleInterceptor</class-name>
- </remoting-incoming-interceptors>
-
- <!-- Acceptors -->
- <acceptors>
- <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor>
- </acceptors>
-
- <!-- 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/6b17d966/examples/broker-features/standard/interceptor/src/main/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/interceptor/src/main/resources/jndi.properties b/examples/broker-features/standard/interceptor/src/main/resources/jndi.properties
deleted file mode 100644
index 93537c4..0000000
--- a/examples/broker-features/standard/interceptor/src/main/resources/jndi.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory
-connectionFactory.ConnectionFactory=tcp://localhost:61616
-queue.queue/exampleQueue=exampleQueue
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/jms-auto-closeable/pom.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/jms-auto-closeable/pom.xml b/examples/broker-features/standard/jms-auto-closeable/pom.xml
deleted file mode 100644
index 844d859..0000000
--- a/examples/broker-features/standard/jms-auto-closeable/pom.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.
--->
-
-<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>auto-closeable</artifactId>
- <packaging>jar</packaging>
- <name>ActiveMQ Artemis JMS Auto Closable 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>
- <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.JMSAutoCloseableExample</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>auto-closeable</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/jms-auto-closeable/readme.html
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/jms-auto-closeable/readme.html b/examples/broker-features/standard/jms-auto-closeable/readme.html
deleted file mode 100644
index 80dc410..0000000
--- a/examples/broker-features/standard/jms-auto-closeable/readme.html
+++ /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.
--->
-
-<html>
- <head>
- <title>ActiveMQ Artemis JMS Auto Closable 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 Auto Closable 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 JMS resources, such as connections, sessions and consumers, in JMS 2 can be automatically closed on error.</p>
- <p>In this instance we auto close a connection after a subsequent call to a JMS producer send fails</p>
-
- <h2>Example step-by-step</h2>
-
- <ol>
- <li>First we need to get an initial context so we can look-up the JMS connection factory and destination objects from JNDI. This initial context will get it's properties from the <code>client-jndi.properties</code> file in the directory <code>../common/config</code></li>
- <pre class="prettyprint">
- <code>InitialContext initialContext = getContext();</code>
- </pre>
-
- <li>We look-up the JMS queue object from JNDI</li>
- <pre class="prettyprint">
- <code>Queue queue = (Queue) initialContext.lookup("/queue/exampleQueue");</code>
- </pre>
-
- <li>We look-up the JMS connection factory object from JNDI</li>
- <pre class="prettyprint">
- <code>ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("/ConnectionFactory");</code>
- </pre>
-
- <li>We create a JMS context but we do it inside the try-with-resources statement like so:</li>
- <pre class="prettyprint">
- <code>
- try
- (
- JMSContext jmsContext = cf.createContext()
- )
- </code>
- </pre>
-
- <li>Inside the following try block we first create the producer</li>
- <pre class="prettyprint">
- <code>JMSProducer jmsProducer = jmsContext.createProducer();</code>
- </pre>
-
- <li>We then try to send a message. It is this call that throws an exception as the producer doesn't have the privileges
- to send a message</li>
- <pre class="prettyprint">
- <code>jmsProducer.send(queue, "this message will fail security!");</code>
- </pre>
-
- <li>We catch the exception from the send message and can do what we want, however the JMSContext will have been closed
- prior to entering the catch block.</li>
- <pre class="prettyprint">
- <code>System.out.println("expected exception from jmsProducer.send: " + e.getMessage());</code>
- </pre>
-
- <li>And finally, we close the Initial Context, note we no longer have to worry about clearing up the JMSContext.</li>
-
- <pre class="prettyprint">
- <code>finally
- {
- if (initialContext != null)
- {
- initialContext.close();
- }
- }</code>
- </pre>
-
-
-
- </ol>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/jms-auto-closeable/src/main/java/org/apache/activemq/artemis/jms/example/JMSAutoCloseableExample.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/jms-auto-closeable/src/main/java/org/apache/activemq/artemis/jms/example/JMSAutoCloseableExample.java b/examples/broker-features/standard/jms-auto-closeable/src/main/java/org/apache/activemq/artemis/jms/example/JMSAutoCloseableExample.java
deleted file mode 100644
index d53a373..0000000
--- a/examples/broker-features/standard/jms-auto-closeable/src/main/java/org/apache/activemq/artemis/jms/example/JMSAutoCloseableExample.java
+++ /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.
- */
-package org.apache.activemq.artemis.jms.example;
-
-import javax.jms.JMSContext;
-import javax.jms.JMSProducer;
-import javax.jms.Queue;
-
-import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
-import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
-
-/**
- * A simple JMS example that shows how AutoCloseable is used by JMS 2 resources.
- */
-public class JMSAutoCloseableExample {
-
- public static void main(final String[] args) throws Exception {
- // Step 2. Perfom a lookup on the queue
- Queue queue = ActiveMQJMSClient.createQueue("exampleQueue");
-
- // Step 4.Create a JMS Context using the try-with-resources statement
- try
- (
- // Even though ConnectionFactory is not closeable it would be nice to close an ActiveMQConnectionFactory
- ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory();
- JMSContext jmsContext = cf.createContext()
- ) {
- // Step 5. create a jms producer
- JMSProducer jmsProducer = jmsContext.createProducer();
-
- // Step 6. Try sending a message, we don't have the appropriate privileges to do this so this will throw an exception
- jmsProducer.send(queue, "A Message from JMS2!");
-
- System.out.println("Received:" + jmsContext.createConsumer(queue).receiveBody(String.class));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/jms-auto-closeable/src/main/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/jms-auto-closeable/src/main/resources/jndi.properties b/examples/broker-features/standard/jms-auto-closeable/src/main/resources/jndi.properties
deleted file mode 100644
index 93537c4..0000000
--- a/examples/broker-features/standard/jms-auto-closeable/src/main/resources/jndi.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory
-connectionFactory.ConnectionFactory=tcp://localhost:61616
-queue.queue/exampleQueue=exampleQueue
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/jms-bridge/jms-bridge.png
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/jms-bridge/jms-bridge.png b/examples/broker-features/standard/jms-bridge/jms-bridge.png
deleted file mode 100644
index d671bf3..0000000
Binary files a/examples/broker-features/standard/jms-bridge/jms-bridge.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/jms-bridge/pom.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/jms-bridge/pom.xml b/examples/broker-features/standard/jms-bridge/pom.xml
deleted file mode 100644
index 35a5363..0000000
--- a/examples/broker-features/standard/jms-bridge/pom.xml
+++ /dev/null
@@ -1,159 +0,0 @@
-<?xml version='1.0'?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.activemq.examples.broker</groupId>
- <artifactId>jms-examples</artifactId>
- <version>1.0.1-SNAPSHOT</version>
- </parent>
-
- <artifactId>bridge</artifactId>
- <packaging>jar</packaging>
- <name>ActiveMQ Artemis JMS Bridge Example</name>
-
- <properties>
- <activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-jms-server</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-jms-client</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.activemq</groupId>
- <artifactId>artemis-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>create0</id>
- <goals>
- <goal>create</goal>
- </goals>
- <configuration>
- <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.JMSBridgeExample</clientClass>
- </configuration>
- </execution>
- <execution>
- <id>stop0</id>
- <goals>
- <goal>cli</goal>
- </goals>
- <configuration>
- <ignore>${noServer}</ignore>
- <location>${basedir}/target/server0</location>
- <args>
- <param>stop</param>
- </args>
- </configuration>
- </execution>
- <execution>
- <id>stop1</id>
- <goals>
- <goal>cli</goal>
- </goals>
- <configuration>
- <ignore>${noServer}</ignore>
- <location>${basedir}/target/server1</location>
- <args>
- <param>stop</param>
- </args>
- </configuration>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.apache.activemq.examples.broker</groupId>
- <artifactId>bridge</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/jms-bridge/readme.html
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/jms-bridge/readme.html b/examples/broker-features/standard/jms-bridge/readme.html
deleted file mode 100644
index 1ee0ff6..0000000
--- a/examples/broker-features/standard/jms-bridge/readme.html
+++ /dev/null
@@ -1,246 +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 Bridge Example</title>
- <link rel="stylesheet" type="text/css" href="../../../common/common.css" />
- <link rel="stylesheet" type="text/css" href="../../../common/prettify.css" />
- <script type="text/javascript" src="../../../common/prettify.js"></script>
- </head>
- <body onload="prettyPrint()">
- <h1>JMS Bridge Example</h1>
-
- <pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre>
-
- <p>This example shows you how to create a JMS Bridge between two ActiveMQ Artemis servers.</p>
- <img src="jms-bridge.png" />
- <p>The example will use two ActiveMQ Artemis servers:</p>
- <ul>
- <li>Server #0 – the <em>Source</em> server. It will be configured with a JMS Topic bound to JNDI under <code>source/topic</code>
- <li>Server #1 – the <em>Target</em> server. It will be configured with a JMS Queue bound to JNDI under <code>target/queue</code><br />
- </ul>
- <p>Both ActiveMQ Artemis server will run their own JNDI server used by the JMS Bridge and the JMS Client to lookup JMS
- resources (ConnectionFactory and Destination).</p>
- <p>The JMS Bridge will be started in the example code and be configured to bridge messages from the <em>source</em> destination
- (the topic hosted on server #0) and the <em>target</em> destination (the queue hosted on server #1)</p>
- <p>The client will check the bridge works by:</p>
- <ol>
- <li>sending a message to the <em>source</em> topic</li>
- <li>receive a message from the <em>target</em> queue</li>
- <li>check that both messages correspond to the same content.</li>
- </ol>
- <h3>JMS Bridge Configuration</h3>
- <p>The JMS Bridge is a <abbr title="Plain Old Java Object">POJO</abbr> that we configure with both source and target
- JNDI configurations. In the actual example we are programatically creating the Bridge, however the following section
- describes how you would do this if you wanted to deploy with an actual ActiveMQ Artemis server via the activemq-beans.xml.
-
- <h4>Configuring the Bridge with the JBoss Microcontainer</h4>
- <p>
- in which we inject JNDI configurations
- so that it looks up its source and target JMS resources.
- The JMS Bridge is defined a bean and setup by JBoss Microntainer in the same VM than Server #1, the target server.</p>
-
- </p>The JMS Bridge sample configuration can be found in <code>resources/activemq-beans.xml</code>, firstly we define the
- Bridge itself:</p>
- <pre class="prettyprint">
- <!-- The JMS Bridge -->
- <bean name="JMSBridge" class="org.apache.activemq.artemis.jms.bridge.impl.JMSBridgeImpl">
- ...
- </bean>
- </pre>
- <p>the <code>JMSBridgeImpl</code> constructor is used to inject all the properties required to run the JMS Bridge.</p>
- <p>Its first four arguments defines how the bridge will lookup:</p>
- <ol>
- <li>its <em>source</em> JMS ConnectionFactory</li>
- <li>its <em>source</em> JMS Destination</li>
- <li>its <em>target</em> JMS ConnectionFactory</li>
- <li>its <em>target</em> JMS Destination</li>
- </ol>
- <p>Using other POJOs, the JMS Bridge is configured to retrieve:</p>
- <ul>
- <li>its <em>source</em> JMS ConnectionFactory by looking up <code>/source/ConnectionFactory</code> using
- the <code>SourceJNDI</code> configuration</li>
- <li>its <em>source</em> JMS Destination by looking up <code>/source/topic</code> using
- the <code>SourceJNDI</code> configuration</li>
- <li>its <em>target</em> JMS ConnectionFactory by looking up <code>/target/ConnectionFactory</code> using
- the <code>TargetJNDI</code> configuration</li>
- <li>its <em>target</em> JMS ConnectionFactory by looking up <code>/target/queue</code> using
- the <code>TargetJNDI</code> configuration</li>
- </ul>
- <p>In turn, <code>SourceJNDI</code> and <code>TargetJNDI</code> are POJOs defining how to connect to JNDI server.
- SourceJNDI URL must point to your source server, while LocalJNDI must point to your target server:</p>
- <pre class="prettyprint">
- <bean name="SourceJNDI" class="java.util.Hashtable">
- ...
- <entry>
- <key>java.naming.provider.url</key>
- <!-- **************************************** -->
- <!-- Replace with the *source* server address -->
- <!-- **************************************** -->
- <value>jnp://192.168.0.10:1099</value>
- ...
- </bean>
- <bean name="TargetJNDI" class="java.util.Hashtable">
- ...
- <ntry>
- <key>java.naming.provider.url</key>
- <!-- **************************************** -->
- <!-- Replace with the *target* server address -->
- <!-- **************************************** -->
- <value>jnp://1192.168.0.11:1099</value>
- </entry>
- ...
- </bean>
- </pre>
- <h2>Example step-by-step</h2>
- <p>To run the example after having setup both ActiveMQ Artemis servers and the JMS bridge:</p>
- <ol>
- <li>To run the example simply run <code>mvn verify -Pexample</code></li>
- </ol>
- <p>Let's look at the Client code (in <code>JMSBridgeExample</code> class):</p>
- <ol>
- <li>First we need to get an initial context so we can look-up the JMS resources</li>
- <pre class="prettyprint">
- InitialContext sourceContext = createContext(sourceServer);
- InitialContext targetContext = createContext(targetServer);
- </pre>
- <li>We then create a JMS Bridge and start it, Note, for certain quality of service modes such as
- ONCE_AND_ONCE_ONLY and AT_LEAST_ONCE a Transaction Manager is required to ensure Messages are delivered
- accordingly. A Transaction Manager can be either loaded via implementation of TransactionManagerLocator intefer
- and loaded via standard a ServiceLoader or by explicitly setting an instance of a Transaction Manager on the
- bridge using setTranscationManager(TransactionManager tm) method. In this example we'll be using the DUPLICATES_OK
- quality of service so there is no need for a Transaction Manager.
- <pre class="prettyprint">
- JMSBridge jmsBridge = new JMSBridgeImpl(
- new JNDIConnectionFactoryFactory(sourceJndiParams, "source/ConnectionFactory"),
- new JNDIConnectionFactoryFactory(targetJndiParams, "target/ConnectionFactory"),
- new JNDIDestinationFactory(sourceJndiParams, "source/topic"),
- new JNDIDestinationFactory(targetJndiParams, "target/queue"),
- null,
- null,
- null,
- null,
- null,
- 5000,
- 10,
- QualityOfServiceMode.DUPLICATES_OK,
- 1,
- -1,
- null,
- null,
- true);
- ....
- jmsBridge.start();
- </pre>
- <li>We look up the JMS resources from the Source server</li>
- <pre class="prettyprint">
- ConnectionFactory sourceConnectionFactory = (ConnectionFactory)sourceContext.lookup("source/ConnectionFactory");
- Topic sourceTopic = (Topic)sourceContext.lookup("source/topic");
- </pre>
-
- <li>We create JMS objects to send a message to the source destination</li>
- <pre class="prettyprint">
- sourceConnection = sourceConnectionFactory.createConnection();
- Session sourceSession = sourceConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer sourceProducer = sourceSession.createProducer(sourceTopic);
- </pre>
-
- <li>We send a message to the source destination</li>
- <pre class="prettyprint">
- TextMessage message = sourceSession.createTextMessage("this is a text message sent at " + System.currentTimeMillis());
- sourceProducer.send(message);
- </pre>
-
- <li>We close the connection to the source server</li>
- <pre class="prettyprint">
- sourceConnection.close();
- </pre>
-
- <p>At this point, the JMS Bridge will consume the message from the source topic and
- sends it to the target queue.
- The client will check the bridge works by consuming a message from the target queue.</p>
-
- <li>We look up the JMS resources from the target server</li>
- <pre class="prettyprint">
- ConnectionFactory targetConnectionFactory = (ConnectionFactory)targetContext.lookup("target/ConnectionFactory");
- Queue targetQueue = (Queue)targetContext.lookup("target/queue");
- </pre>
-
- <li>We create JMS objects to receive a message from the target destination</li>
- <pre class="prettyprint">
- targetConnection = targetConnectionFactory.createConnection();
- Session targetSession = targetConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer targetConsumer = targetSession.createConsumer(targetQueue);
- </pre>
-
- <li>We start the target connection to start receiving messages
- <pre class="prettyprint">
- targetConnection.start();
- </pre>
-
- <li>We receive the message and print it. Its content is the same than the message
- the client sent to the source topic</li>
- <pre class="prettyprint">
- TextMessage messageReceived = (TextMessage)targetConsumer.receive(5000);
- </pre>
-
- <li>We display the message ID and its "bridged" message ID</li>
- <pre class="prettyprint">
- System.out.format("Message ID : %s\n", messageReceived.getJMSMessageID());
- System.out.format("Bridged Message ID : %s\n", messageReceived.getStringProperty("AMQ_BRIDGE_MSG_ID_LIST"));
- </pre>
-
- <p>Note that the message received from the target queue is <em>not the same message</em> sent to the source topic
- (their message IDs are different) but they have the <em>same content</em>.
-
- <li>And finally, we stop the Bridge and <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
-
- <pre class="prettyprint">
- <code>finally
- {
- if (jmsBridge != null)
- {
- jmsBridge.stop();
- }
- 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/appserver-integration.html#jms-bridge">JMS Bridge chapter</a></li>
- <li>The <a href="../../javaee/jms-bridge/readme.html">Java EE JMS Bridge example</a> shows how to configure a JMS Bridge
- inside JBoss Application Server to bridge destinations from the same server.</a>
- </p>
-
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/jms-bridge/src/main/java/org/apache/activemq/artemis/jms/example/JMSBridgeExample.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/jms-bridge/src/main/java/org/apache/activemq/artemis/jms/example/JMSBridgeExample.java b/examples/broker-features/standard/jms-bridge/src/main/java/org/apache/activemq/artemis/jms/example/JMSBridgeExample.java
deleted file mode 100644
index 8a65cd5..0000000
--- a/examples/broker-features/standard/jms-bridge/src/main/java/org/apache/activemq/artemis/jms/example/JMSBridgeExample.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.artemis.jms.example;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-import javax.naming.InitialContext;
-import java.util.Hashtable;
-
-import org.apache.activemq.artemis.jms.bridge.JMSBridge;
-import org.apache.activemq.artemis.jms.bridge.QualityOfServiceMode;
-import org.apache.activemq.artemis.jms.bridge.impl.JMSBridgeImpl;
-import org.apache.activemq.artemis.jms.bridge.impl.JNDIConnectionFactoryFactory;
-import org.apache.activemq.artemis.jms.bridge.impl.JNDIDestinationFactory;
-
-/**
- * An example which sends a message to a source topic and consume from a target queue.
- * The source and target destinations are located on 2 different ActiveMQ Artemis server.
- * The source and target queues are bridged by a JMS Bridge configured and running on the "target" server.
- */
-public class JMSBridgeExample {
-
- public static void main(final String[] args) throws Exception {
- String sourceServer = "tcp://localhost:61616";
- String targetServer = "tcp://localhost:61617";
-
- System.out.println("client will publish messages to " + sourceServer +
- " and receives message from " +
- targetServer);
-
- // Step 1. Create JNDI contexts for source and target servers
- InitialContext sourceContext = JMSBridgeExample.createContext(sourceServer);
- InitialContext targetContext = JMSBridgeExample.createContext(targetServer);
-
- Hashtable<String, String> sourceJndiParams = createJndiParams(sourceServer);
- Hashtable<String, String> targetJndiParams = createJndiParams(targetServer);
- // Step 2. Create and start a JMS Bridge
- // Note, the Bridge needs a transaction manager, in this instance we will use the JBoss TM
- JMSBridge jmsBridge = new JMSBridgeImpl(new JNDIConnectionFactoryFactory(sourceJndiParams, "ConnectionFactory"), new JNDIConnectionFactoryFactory(targetJndiParams, "ConnectionFactory"), new JNDIDestinationFactory(sourceJndiParams, "source/topic"), new JNDIDestinationFactory(targetJndiParams, "target/queue"), null, null, null, null, null, 5000, 10, QualityOfServiceMode.DUPLICATES_OK, 1, -1, null, null, true);
-
- Connection sourceConnection = null;
- Connection targetConnection = null;
- try {
- jmsBridge.start();
- // Step 3. Lookup the *source* JMS resources
- ConnectionFactory sourceConnectionFactory = (ConnectionFactory) sourceContext.lookup("ConnectionFactory");
- Topic sourceTopic = (Topic) sourceContext.lookup("source/topic");
-
- // Step 4. Create a connection, a session and a message producer for the *source* topic
- sourceConnection = sourceConnectionFactory.createConnection();
- Session sourceSession = sourceConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer sourceProducer = sourceSession.createProducer(sourceTopic);
-
- // Step 5. Create and send a text message to the *source* queue
- TextMessage message = sourceSession.createTextMessage("this is a text message sent at " + System.currentTimeMillis());
- sourceProducer.send(message);
- System.out.format("Sent message to %s: %s%n", ((Topic) message.getJMSDestination()).getTopicName(), message.getText());
- System.out.format("Message ID : %s%n", message.getJMSMessageID());
-
- // Step 6. Close the *source* connection
- sourceConnection.close();
-
- // Step 7. Lookup the *target* JMS resources
- ConnectionFactory targetConnectionFactory = (ConnectionFactory) targetContext.lookup("ConnectionFactory");
- Queue targetQueue = (Queue) targetContext.lookup("target/queue");
-
- // Step 8. Create a connection, a session and a message consumer for the *target* queue
- targetConnection = targetConnectionFactory.createConnection();
- Session targetSession = targetConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer targetConsumer = targetSession.createConsumer(targetQueue);
-
- // Step 9. Start the connection to receive messages from the *target* queue
- targetConnection.start();
-
- // Step 10. Receive a message from the *target* queue
- TextMessage messageReceived = (TextMessage) targetConsumer.receive(5000);
- System.out.format("%nReceived from %s: %s%n", ((Queue) messageReceived.getJMSDestination()).getQueueName(), messageReceived.getText());
-
- // Step 11. Display the received message's ID and this "bridged" message ID
- System.out.format("Message ID : %s%n", messageReceived.getJMSMessageID());
- System.out.format("Bridged Message ID : %s%n", messageReceived.getStringProperty("AMQ_BRIDGE_MSG_ID_LIST"));
- }
- finally {
- // Step 12. Be sure to close the resources!
- if (jmsBridge != null) {
- jmsBridge.stop();
- }
- if (sourceContext != null) {
- sourceContext.close();
- }
- if (targetContext != null) {
- targetContext.close();
- }
- if (sourceConnection != null) {
- sourceConnection.close();
- }
- if (targetConnection != null) {
- targetConnection.close();
- }
- }
- }
-
- private static InitialContext createContext(final String server) throws Exception {
- Hashtable<String, String> jndiProps = createJndiParams(server);
- return new InitialContext(jndiProps);
- }
-
- private static Hashtable<String, String> createJndiParams(String server) {
- Hashtable<String, String> jndiProps = new Hashtable<String, String>();
- jndiProps.put("connectionFactory.ConnectionFactory", server);
- jndiProps.put("java.naming.factory.initial", "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory");
- jndiProps.put("queue.target/queue", "target");
- jndiProps.put("topic.source/topic", "topic");
- return jndiProps;
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/jms-bridge/src/main/resources/activemq/server0/artemis-roles.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/jms-bridge/src/main/resources/activemq/server0/artemis-roles.properties b/examples/broker-features/standard/jms-bridge/src/main/resources/activemq/server0/artemis-roles.properties
deleted file mode 100644
index 4e2d44c..0000000
--- a/examples/broker-features/standard/jms-bridge/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/6b17d966/examples/broker-features/standard/jms-bridge/src/main/resources/activemq/server0/artemis-users.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/jms-bridge/src/main/resources/activemq/server0/artemis-users.properties b/examples/broker-features/standard/jms-bridge/src/main/resources/activemq/server0/artemis-users.properties
deleted file mode 100644
index 4e2d44c..0000000
--- a/examples/broker-features/standard/jms-bridge/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/6b17d966/examples/broker-features/standard/jms-bridge/src/main/resources/activemq/server0/broker.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/jms-bridge/src/main/resources/activemq/server0/broker.xml b/examples/broker-features/standard/jms-bridge/src/main/resources/activemq/server0/broker.xml
deleted file mode 100644
index df456d7..0000000
--- a/examples/broker-features/standard/jms-bridge/src/main/resources/activemq/server0/broker.xml
+++ /dev/null
@@ -1,53 +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">
- <topic name="topic"/>
- </jms>
-
- <core xmlns="urn:activemq:core">
-
- <bindings-directory>${data.dir:../data}/bindings</bindings-directory>
-
- <journal-directory>${data.dir:../data}/journal</journal-directory>
-
- <large-messages-directory>${data.dir:../data}/largemessages</large-messages-directory>
-
- <paging-directory>${data.dir:../data}/paging</paging-directory>
-
- <acceptors>
- <acceptor name="netty">tcp://localhost:61616</acceptor>
- </acceptors>
-
- <security-settings>
- <security-setting match="jms.#">
- <permission type="consume" roles="guest"/>
- <permission type="send" roles="guest"/>
- <permission type="createNonDurableQueue" roles="guest"/>
- <permission type="deleteNonDurableQueue" roles="guest"/>
- </security-setting>
- </security-settings>
- </core>
-</configuration>
-
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/jms-bridge/src/main/resources/activemq/server1/artemis-roles.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/jms-bridge/src/main/resources/activemq/server1/artemis-roles.properties b/examples/broker-features/standard/jms-bridge/src/main/resources/activemq/server1/artemis-roles.properties
deleted file mode 100644
index 4e2d44c..0000000
--- a/examples/broker-features/standard/jms-bridge/src/main/resources/activemq/server1/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/6b17d966/examples/broker-features/standard/jms-bridge/src/main/resources/activemq/server1/artemis-users.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/jms-bridge/src/main/resources/activemq/server1/artemis-users.properties b/examples/broker-features/standard/jms-bridge/src/main/resources/activemq/server1/artemis-users.properties
deleted file mode 100644
index 4e2d44c..0000000
--- a/examples/broker-features/standard/jms-bridge/src/main/resources/activemq/server1/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/6b17d966/examples/broker-features/standard/jms-bridge/src/main/resources/activemq/server1/broker.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/jms-bridge/src/main/resources/activemq/server1/broker.xml b/examples/broker-features/standard/jms-bridge/src/main/resources/activemq/server1/broker.xml
deleted file mode 100644
index e65720c..0000000
--- a/examples/broker-features/standard/jms-bridge/src/main/resources/activemq/server1/broker.xml
+++ /dev/null
@@ -1,53 +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">
- <queue name="target"/>
- </jms>
-
- <core xmlns="urn:activemq:core">
-
- <bindings-directory>${data.dir:../data}/bindings</bindings-directory>
-
- <journal-directory>${data.dir:../data}/journal</journal-directory>
-
- <large-messages-directory>${data.dir:../data}/largemessages</large-messages-directory>
-
- <paging-directory>${data.dir:../data}/paging</paging-directory>
-
- <acceptors>
- <acceptor name="netty">tcp://localhost:61617</acceptor>
- </acceptors>
-
- <security-settings>
- <security-setting match="jms.#">
- <permission type="consume" roles="guest"/>
- <permission type="send" roles="guest"/>
- <permission type="createNonDurableQueue" roles="guest"/>
- <permission type="deleteNonDurableQueue" roles="guest"/>
- </security-setting>
- </security-settings>
- </core>
-</configuration>
-
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/jms-completion-listener/pom.xml
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/jms-completion-listener/pom.xml b/examples/broker-features/standard/jms-completion-listener/pom.xml
deleted file mode 100644
index 139432f..0000000
--- a/examples/broker-features/standard/jms-completion-listener/pom.xml
+++ /dev/null
@@ -1,110 +0,0 @@
-<?xml version='1.0'?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.activemq.examples.broker</groupId>
- <artifactId>jms-examples</artifactId>
- <version>1.0.1-SNAPSHOT</version>
- </parent>
-
- <artifactId>completion-listener</artifactId>
- <packaging>jar</packaging>
- <name>ActiveMQ Artemis JMS Completion Listener 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>${basedir}/target/classes/activemq/server0</configuration>
- </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.JMSCompletionListenerExample</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>completion-listener</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/jms-completion-listener/readme.html
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/jms-completion-listener/readme.html b/examples/broker-features/standard/jms-completion-listener/readme.html
deleted file mode 100644
index 36be17a..0000000
--- a/examples/broker-features/standard/jms-completion-listener/readme.html
+++ /dev/null
@@ -1,112 +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 Completion Listener 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 Completion Listener Example</h1>
-
- <pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre>
-
- <p>This example shows you how to send a message asynchronously to ActiveMQ Artemis and use a CompletionListener to be notified of
- the Broker receiving it</p>
-
- <h2>Example step-by-step</h2>
-
- <ol>
- <li>First we need to get an initial context so we can look-up the JMS connection factory and destination objects from JNDI. This initial context will get it's properties from the <code>client-jndi.properties</code> file in the directory <code>../common/config</code></li>
- <pre class="prettyprint">
- <code>InitialContext initialContext = getContext();</code>
- </pre>
-
- <li>We look-up the JMS queue object from JNDI</li>
- <pre class="prettyprint">
- <code>Queue queue = (Queue) initialContext.lookup("/queue/exampleQueue");</code>
- </pre>
-
- <li>We look-up the JMS connection factory object from JNDI</li>
- <pre class="prettyprint">
- <code>ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("/ConnectionFactory");</code>
- </pre>
-
- <li>We create a JMS context</li>
- <pre class="prettyprint">
- <code>jmsContext = cf.createContext();</code>
- </pre>
-
- <li>We create a JMS Producer.</li>
- <pre class="prettyprint">
- <code>JMSProducer producer = jmsContext.createProducer();</code>
- </pre>
-
- <li>We set a CompletionListener on the Producer</li>
- <pre class="prettyprint">
- <code>producer.setAsync(new CompletionListener()
- {
- @Override
- public void onCompletion(Message message)
- {
- System.out.println("message acknowledged by ActiveMQ");
- latch.countDown();
- }
-
- @Override
- public void onException(Message message, Exception e)
- {
- e.printStackTrace();
- }
- });</code>
- </pre>
-
- <li>We send a message</li>
- <pre class="prettyprint">
- <code>producer.send(queue, "this is a string");</code>
- </pre>
-
- <li> and then wait for the Completion Listener to be called</li>
- <pre class="prettyprint">
- <code>return latch.await(5, TimeUnit.SECONDS);</code>
- </pre>
-
- <li>And finally, <b>always</b> remember to close your JMS connections and resources after use, in a <code>finally</code> block. Closing a JMS connection will automatically close all of its sessions, consumers, producer and browser objects</li>
-
- <pre class="prettyprint">
- <code>finally
- {
- if (initialContext != null)
- {
- initialContext.close();
- }
- if (jmsContext != null)
- {
- jmsContext.close();
- }
- }</code>
- </pre>
-
-
-
- </ol>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/jms-completion-listener/src/main/java/org/apache/activemq/artemis/jms/example/JMSCompletionListenerExample.java
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/jms-completion-listener/src/main/java/org/apache/activemq/artemis/jms/example/JMSCompletionListenerExample.java b/examples/broker-features/standard/jms-completion-listener/src/main/java/org/apache/activemq/artemis/jms/example/JMSCompletionListenerExample.java
deleted file mode 100644
index 4688ba3..0000000
--- a/examples/broker-features/standard/jms-completion-listener/src/main/java/org/apache/activemq/artemis/jms/example/JMSCompletionListenerExample.java
+++ /dev/null
@@ -1,82 +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.CompletionListener;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSContext;
-import javax.jms.JMSProducer;
-import javax.jms.Message;
-import javax.jms.Queue;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
-import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
-
-/**
- * A JMS Completion Listener Example.
- */
-public class JMSCompletionListenerExample {
-
- public static void main(final String[] args) throws Exception {
- JMSContext jmsContext = 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?confirmationWindowSize=10240");
-
- // Step 4.Create a JMS Context
- jmsContext = cf.createContext();
-
- // Step 5. Create a message producer.
- JMSProducer producer = jmsContext.createProducer();
-
- final CountDownLatch latch = new CountDownLatch(1);
-
- //Step 6. We want to send the message Asynchronously and be notified when the Broker receives it so we set a completion handler
- producer.setAsync(new CompletionListener() {
- @Override
- public void onCompletion(Message message) {
- System.out.println("message acknowledged by ActiveMQ");
- latch.countDown();
- }
-
- @Override
- public void onException(Message message, Exception e) {
- e.printStackTrace();
- }
- });
-
- //Step 6. Send the Message
- producer.send(queue, "this is a string");
-
- //Step 7. wait for the Completion handler
- if (!latch.await(5, TimeUnit.SECONDS)) {
- throw new IllegalStateException("Completion listener not called as expected.");
- }
- }
- finally {
- if (jmsContext != null) {
- jmsContext.close();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/jms-completion-listener/src/main/resources/jndi.properties
----------------------------------------------------------------------
diff --git a/examples/broker-features/standard/jms-completion-listener/src/main/resources/jndi.properties b/examples/broker-features/standard/jms-completion-listener/src/main/resources/jndi.properties
deleted file mode 100644
index 93537c4..0000000
--- a/examples/broker-features/standard/jms-completion-listener/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