http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/core/vertx-connector/readme.html ---------------------------------------------------------------------- diff --git a/examples/core/vertx-connector/readme.html b/examples/core/vertx-connector/readme.html deleted file mode 100644 index a91735f..0000000 --- a/examples/core/vertx-connector/readme.html +++ /dev/null @@ -1,103 +0,0 @@ -<!-- -Licensed to the Apache Software Foundation (ASF) under one -or more contributor license agreements. See the NOTICE file -distributed with this work for additional information -regarding copyright ownership. The ASF licenses this file -to you under the Apache License, Version 2.0 (the -"License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, -software distributed under the License is distributed on an -"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, either express or implied. See the License for the -specific language governing permissions and limitations -under the License. ---> - -<html> - <head> - <title>ActiveMQ Artemis Vert.x Connector Service 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>Vert.x Connector Service Example</h1> - - <p>This example shows you how to configure ActiveMQ Artemis to use the Vert.x Connector Service.</p> - - <p>ActiveMQ Artemis supports 2 types of Vert.x connector, incoming and outgoing. - Incoming connector consumes from Vert.x event bus and forwards to a configurable address. - Outgoing connector consumes from a configurable address and forwards to a configurable Vert.x event bus. - </p> - - <p>In this example, an incoming connector and an outgoing connector are configured. A simple java Verticle - is deployed. The verticle registers a message handler on the outgoing connector's address ("outgoing.vertx.address"). - A String message is sent to Vert.x event bus on the incoming connector's address("incoming.vertx.address"). - The message then will be forwarded to a ActiveMQ Artemis queue by the incoming connector. The outgoing connector listens to - the ActiveMQ Artemis queue and forwards the message from ActiveMQ Artemis to Vert.x event bus on the outgoing connector's address. - The verticle finally receives the message from it's event bus.</p> - - <p>For more information on Vert.x concept please visit the <a href="http://vertx.io/">Vertx site</a></p> - - <h2>Example step-by-step</h2> - <p><i>To run the server, simply type <code>mvn verify</code> - from this directory.</p> - - <ol> - <li>First we need to create a Vert.x PlatformManager</li> - <pre class="prettyprint"> - <code>platformManager = PlatformLocator.factory.createPlatformManager(PORT, HOST);</code> - </pre> - - <li>We deploy a Verticle using the platformManager</li> - <pre class="prettyprint"> - <code>String verticle = "org.apache.activemq.artemis.core.example.ExampleVerticle"; - platformManager.deployVerticle(verticle, null, new URL[0], 1, null, - new Handler<AsyncResult<String>>(){ - - @Override - public void handle(AsyncResult<String> result) - { - if (!result.succeeded()) - { - throw new RuntimeException("failed to deploy verticle", result.cause()); - } - latch0.countDown(); - } - - });</code> - </pre> - - <li>We register a message handler with the event bus in the Verticle to listen on the outgoing connector's address.</li> - <pre class="prettyprint"> - <code>EventBus eventBus = vertx.eventBus(); - eventBus.registerHandler(VertxConnectorExample.OUTGOING, - new Handler<Message<?>>() { - @Override - public void handle(Message<?> startMsg) - { - Object body = startMsg.body(); - System.out.println("Verticle receives a message: " + body); - VertxConnectorExample.result.set(VertxConnectorExample.MSG.equals(body)); - latch0.countDown(); - } - }); - </code> - </pre> - - <li>We send a message to incoming connector's address via event bus</li> - <pre class="prettyprint"> - <code> - EventBus bus = platformManager.vertx().eventBus(); - bus.send(INCOMING, MSG); - </code> - </pre> - - <li>The message will eventually arrives at the Verticle's message handler.</li> - </ol> - </body> -</html>
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/core/vertx-connector/src/main/java/org/apache/activemq/artemis/core/example/ExampleVerticle.java ---------------------------------------------------------------------- diff --git a/examples/core/vertx-connector/src/main/java/org/apache/activemq/artemis/core/example/ExampleVerticle.java b/examples/core/vertx-connector/src/main/java/org/apache/activemq/artemis/core/example/ExampleVerticle.java deleted file mode 100644 index 50a8f79..0000000 --- a/examples/core/vertx-connector/src/main/java/org/apache/activemq/artemis/core/example/ExampleVerticle.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.activemq.artemis.core.example; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.vertx.java.core.Handler; -import org.vertx.java.core.eventbus.EventBus; -import org.vertx.java.core.eventbus.Message; -import org.vertx.java.platform.Verticle; - -public class ExampleVerticle extends Verticle { - - @Override - public void start() { - EventBus eventBus = vertx.eventBus(); - - final CountDownLatch latch0 = new CountDownLatch(1); - - // Register a handler on the outgoing connector's address - eventBus.registerHandler(VertxConnectorExample.OUTGOING, new Handler<Message<?>>() { - @Override - public void handle(Message<?> startMsg) { - Object body = startMsg.body(); - System.out.println("Verticle receives a message: " + body); - VertxConnectorExample.result.set(VertxConnectorExample.MSG.equals(body)); - latch0.countDown(); - //Tell the example to finish. - VertxConnectorExample.latch.countDown(); - } - }); - - try { - latch0.await(5000, TimeUnit.MILLISECONDS); - } - catch (InterruptedException e) { - } - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/core/vertx-connector/src/main/java/org/apache/activemq/artemis/core/example/VertxConnectorExample.java ---------------------------------------------------------------------- diff --git a/examples/core/vertx-connector/src/main/java/org/apache/activemq/artemis/core/example/VertxConnectorExample.java b/examples/core/vertx-connector/src/main/java/org/apache/activemq/artemis/core/example/VertxConnectorExample.java deleted file mode 100644 index 2194e30..0000000 --- a/examples/core/vertx-connector/src/main/java/org/apache/activemq/artemis/core/example/VertxConnectorExample.java +++ /dev/null @@ -1,105 +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.core.example; - -import java.net.URL; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; - -import org.vertx.java.core.AsyncResult; -import org.vertx.java.core.Handler; -import org.vertx.java.core.eventbus.EventBus; -import org.vertx.java.platform.PlatformLocator; -import org.vertx.java.platform.PlatformManager; -import org.vertx.java.spi.cluster.impl.hazelcast.HazelcastClusterManagerFactory; - -/** - * A simple example of using Vert.x connector service. - */ -public class VertxConnectorExample { - - public static final String INCOMING = "incoming.vertx.address"; - public static final String OUTGOING = "outgoing.vertx.address"; - public static final String MSG = "Welcome to Vertx world!"; - - public final static CountDownLatch latch = new CountDownLatch(1); - public final static AtomicBoolean result = new AtomicBoolean(false); - - private static final String HOST = "127.0.0.1"; - private static final int PORT = 0; - - public static void main(final String[] args) throws Exception { - System.setProperty("vertx.clusterManagerFactory", HazelcastClusterManagerFactory.class.getName()); - PlatformManager platformManager = null; - - try { - // Step 1 Create a Vert.x PlatformManager - platformManager = PlatformLocator.factory.createPlatformManager(PORT, HOST); - - final CountDownLatch latch0 = new CountDownLatch(1); - - // Step 2 Deploy a Verticle to receive message - String verticle = "org.apache.activemq.artemis.core.example.ExampleVerticle"; - platformManager.deployVerticle(verticle, null, new URL[0], 1, null, new Handler<AsyncResult<String>>() { - - @Override - public void handle(AsyncResult<String> result) { - if (!result.succeeded()) { - throw new RuntimeException("failed to deploy verticle", result.cause()); - } - latch0.countDown(); - } - - }); - - latch0.await(); - - // Step 3 Send a message to the incoming connector's address - EventBus bus = platformManager.vertx().eventBus(); - bus.send(INCOMING, MSG); - - // Step 4 Waiting for the Verticle to process the message - latch.await(10000, TimeUnit.MILLISECONDS); - } - finally { - if (platformManager != null) { - platformManager.undeployAll(null); - platformManager.stop(); - } - reportResultAndExit(); - } - } - - private static void reportResultAndExit() { - if (!result.get()) { - System.err.println(); - System.err.println("#####################"); - System.err.println("### FAILURE! ###"); - System.err.println("#####################"); - System.exit(1); - } - else { - System.out.println(); - System.out.println("#####################"); - System.out.println("### SUCCESS! ###"); - System.out.println("#####################"); - System.exit(0); - } - } - -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/core/vertx-connector/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/core/vertx-connector/src/main/resources/activemq/server0/broker.xml b/examples/core/vertx-connector/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 9be6726..0000000 --- a/examples/core/vertx-connector/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,81 +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="urn:activemq" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - 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>target/server0/data/messaging/bindings</bindings-directory> - - <journal-directory>target/server0/data/messaging/journal</journal-directory> - - <large-messages-directory>target/server0/data/messaging/largemessages</large-messages-directory> - - <paging-directory>target/server0/data/messaging/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> - - <!-- Other config --> - - <security-settings> - <!--security for example queue--> - <security-setting match="queue.vertxQueue"> - <permission type="consume" roles="guest"/> - <permission type="send" roles="guest"/> - </security-setting> - </security-settings> - - <queues> - <queue name="queue.vertxQueue"> - <address>queue.vertxQueue</address> - </queue> - </queues> - - <connector-services> - <connector-service name="my-incoming-vertx"> - <factory-class>org.apache.activemq.artemis.integration.vertx.VertxIncomingConnectorServiceFactory</factory-class> - <param key="queue" value="queue.vertxQueue"/> - <param key="host" value="localhost"/> - <param key="port" value="0"/> - <param key="vertx-address" value="incoming.vertx.address"/> - </connector-service> - <connector-service name="my-outgoing-vertx"> - <factory-class>org.apache.activemq.artemis.integration.vertx.VertxOutgoingConnectorServiceFactory</factory-class> - <param key="queue" value="queue.vertxQueue"/> - <param key="host" value="localhost"/> - <param key="port" value="0"/> - <param key="vertx-address" value="outgoing.vertx.address"/> - </connector-service> - </connector-services> - </core> - -</configuration> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/README.md ---------------------------------------------------------------------- diff --git a/examples/jms/README.md b/examples/jms/README.md deleted file mode 100644 index e9d9e36..0000000 --- a/examples/jms/README.md +++ /dev/null @@ -1,32 +0,0 @@ -Running the ActiveMQ Artemis Examples -============================ - -To run an individual example firstly cd into the example directory and run - -```sh -mvn verify -``` - -Most examples offer a way to start them without creating and starting the server (say if you want to do it manually) - -```sh -mvn verify -PnoServer -``` - -If you are running against an un released version, i.e. from master branch, you will have to run `mvn install` on the root -pom.xml and the example/activemq-jms-examples-common/pom.xml first. - -If you want to run all the examples (except those that need to be run standalone) you can run `mvn verify -Pexamples` in the examples -directory but before you do you will need to up the memory used by running: - -``` -export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=256m" -``` -### Recreating the examples - -If you are trying to copy the examples somewhere else and modifying them. Consider asking Maven to explicitly list all the dependencies: - -``` -# if trying to modify the 'topic' example: -cd examples/jms/topic && mvn dependency:list -``` http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/aerogear/pom.xml ---------------------------------------------------------------------- diff --git a/examples/jms/aerogear/pom.xml b/examples/jms/aerogear/pom.xml deleted file mode 100644 index fc224d6..0000000 --- a/examples/jms/aerogear/pom.xml +++ /dev/null @@ -1,134 +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> - - <properties> - <endpoint/> - <applicationid/> - <mastersecret/> - <activemq.basedir>${project.basedir}/../../..</activemq.basedir> - </properties> - - <artifactId>aerogear</artifactId> - <packaging>jar</packaging> - <name>ActiveMQ Artemis JMS AeroGear Example</name> - - <dependencies> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-cli</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> - <!-- this list was extracted from mvn dependency:tree on integration/aerogear --> - <libList> - <param>org.apache.activemq:artemis-aerogear-integration:${project.version}</param> - <param>org.jboss.aerogear:unifiedpush-java-client:1.0.0</param> - <param>net.iharder:base64:2.3.8</param> - <param>com.fasterxml.jackson.core:jackson-annotations:2.3.0</param> - <param>com.fasterxml.jackson.core:jackson-core:2.3.0</param> - <param>org.jboss.resteasy:resteasy-jackson-provider:2.3.2.Final</param> - <param>org.codehaus.jackson:jackson-core-asl:1.8.5</param> - <param>org.codehaus.jackson:jackson-mapper-asl:1.8.5</param> - <param>org.codehaus.jackson:jackson-jaxrs:1.8.5</param> - <param>org.codehaus.jackson:jackson-xc:1.8.5</param> - </libList> - </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.AerogearExample</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>aerogear</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/aerogear/readme.html ---------------------------------------------------------------------- diff --git a/examples/jms/aerogear/readme.html b/examples/jms/aerogear/readme.html deleted file mode 100644 index bdddfa6..0000000 --- a/examples/jms/aerogear/readme.html +++ /dev/null @@ -1,157 +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 AeroGear 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 AeroGear Example</h1> - - - <pre>To run the example, simply type <b>mvn verify</b> from this directory, <br>or <b>mvn -PnoServer verify</b> if you want to start and create the server manually.</pre> - - <p>This example shows how you can send a message to a mobile device by leveraging <a href="http://aerogear.org/push/">AeroGears push</a> technology which - provides support for different push notification technologies like Google Cloud Messaging, Apple's APNs or - Mozilla's SimplePush.</p> - - <p>For this example you will need an AeroGear Application running somewhere, a good way to do this is to deploy the - Push Application on <href a="">openshift</href>, you can follow the AeroGear Push 0.X Quickstart.</p> - - <p>Once you have created your AeroGear Push Application you can create a mobile application. Simply log into the application - on the web and create a new mobile application by clicking the 'create' button. Once created you will see an application id - and a master secret, you will need the later to run the example.</p> - - <p>lastly you will need to create a variant. For this example we will be using Android so you will need to create a google project, - this <a href="http://aerogear.org/docs/guides/aerogear-push-android/google-setup/">article</a> explains how to do this. - Once created click on your app then click 'add' to add a variant. choose 'google cloud messaging', enter your google - API key and the project number from your google project and click create</p> - - <p>Now before we run the example we need a mobile application to receive it. Writing a mobile app is beyond the scope - of this example but for testing purposes we have supplied an Android app you can use, simply install on your android phone. - It can be found <a href="http://downloads.jboss.org.apache.activemq/ActiveMQAeroGear.apk">here</a>. For a more in depth mobile - app example visit the AeroGear site.</p> - - <p>Once you have installed the mobile app you will need to configure the following:</p> - <p>AeroGear Unified Push URL : This is the URL where your aerogear server is running, something like http://myapp-mydomain.rhcloud.com - AeroGear Variant ID : This is the ID of the variant you created in AeroGear - AeroGear Variant Secret : This is the secret for your variant - GCM Sender ID : this is the Google project Number you created on Google - Variant : you can use this to target messages if needed. - </p> - - <p>Once you set all these correctly you should get a message saying your mobile app is registered, if you log into - your AeroGear app you should see it registered with the variant.</p> - - - <p>Now to run the example simply run the following command - 'mvn -Dendpoint=my aerogear url -Dapplicationid=my application id -Dmastersecret=my master secret -Djsse.enableSNIExtension=false clean verify'. - If you arent using java 7 you can omit the 'jsse.enableSNIExtension=false'</p> - - <p>You should see something like this in your ActiveMQServer</p> - <ol> - <pre class="prettyprint"> - <code> - Dec 04, 2013 3:25:39 PM org.jboss.aerogear.unifiedpush.SenderClient submitPayload - INFO: HTTP Response code from UnifiedPush Server: 302 - Dec 04, 2013 3:25:39 PM org.jboss.aerogear.unifiedpush.SenderClient submitPayload - INFO: Performing redirect to 'https://myapp-mydomain.rhcloud.com/rest/sender/' - Dec 04, 2013 3:25:40 PM org.jboss.aerogear.unifiedpush.SenderClient submitPayload - INFO: HTTP Response code from UnifiedPush Server: 200 - </code> - </pre> - </ol> - <p>And on your mobile app you should see a message from ActiveMQ</p> - - <p>Now lets look a bit more closely at the configuration in broker.xml</p> - <ol> - <pre class="prettyprint"> - <code> - <queues> - <queue name="jms.queue.exampleQueue"> - <address>jms.queue.exampleQueue</address> - </queue> - </queues> - - <connector-services> - <connector-service name="aerogear-connector"> - <factory-class>org.apache.activemq.integration.aerogear.AeroGearConnectorServiceFactory</factory-class> - <param key="endpoint" value="${endpoint}"/> - <param key="queue" value="jms.queue.exampleQueue"/> - <param key="application-id" value="${applicationid}"/> - <param key="master-secret" value="${mastersecret}"/> - </connector-service> - </connector-services> - </code> - </pre> - </ol> - <p>Firstly you will see that we have to create a core queue so it is available when the connector is started, the following are mandatory parameters:</p> - <ol> - <li>endpoint - The endpoint or URL of you AeroGear application</li> - <li>queue - The name of the queue to consume from</li> - <li>application-id - The application id of your mobile application in AeroGear</li> - <li>master-secret - the secret of your mobile application in AeroGear</li> - </ol> - <p>as well as those there are also the following optional parameters</p> - <ol> - <li>ttl - The time to live for the message once AeroGear receives it</li> - <li>badge - The badge the mobile app should use for the notification</li> - <li>sound - The sound the mobile app should use for the notification</li> - <li>filter - A message filter(selector) to use on the connector</li> - <li>retry-interval - If an error occurs on send, how long before we try again</li> - <li>retry-attempts - How many times we should try to reconnect after an error</li> - <li>variants - A comma separated list of variants that should get the message</li> - <li>aliases - A list of aliases that should get the message</li> - <li>device-types - A list of device types that should get the message</li> - </ol> - <p>More in depth explanations of these can be found in the AeroGear docs.</p> - <p>Now lets look at a snippet of code we used to send the message for our JMS client</p> - <pre class="prettyprint"> - <code> - 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 - Message message = session.createMessage(); - - message.setStringProperty("AEROGEAR_ALERT", "Hello this is a notification from ActiveMQ"); - - producer.send(message); - </code> - </pre> - <p> The most important thing here is string propert we have set on the message, i.e. 'AEROGEAR_ALERT'. This is the - actual alert that is sent via AeroGear</p> - <p>As well as the alert itself you can override any of the above optional parameters in the same fashionby using the - following propert names: AEROGEAR_SOUND,AEROGEAR_BADGE,AEROGEAR_TTL,AEROGEAR_VARIANTS,AEROGEAR_ALIASES and AEROGEAR_DEVICE_TYPES</p> - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/aerogear/src/main/java/org/apache/activemq/artemis/jms/example/AerogearExample.java ---------------------------------------------------------------------- diff --git a/examples/jms/aerogear/src/main/java/org/apache/activemq/artemis/jms/example/AerogearExample.java b/examples/jms/aerogear/src/main/java/org/apache/activemq/artemis/jms/example/AerogearExample.java deleted file mode 100644 index b412d87..0000000 --- a/examples/jms/aerogear/src/main/java/org/apache/activemq/artemis/jms/example/AerogearExample.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.activemq.artemis.jms.example; - -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.Message; -import javax.jms.MessageProducer; -import javax.jms.Queue; -import javax.jms.Session; -import javax.naming.InitialContext; - -/** - * A simple JMS Queue example that creates a producer and consumer on a queue and sends then receives a message. - */ -public class AerogearExample { - - public static void main(final String[] args) throws Exception { - Connection connection = null; - InitialContext initialContext = null; - try { - // Step 1. Create an initial context to perform the JNDI lookup. - initialContext = new InitialContext(); - - // Step 2. Perfom a lookup on the queue - Queue queue = (Queue) initialContext.lookup("queue/exampleQueue"); - - // Step 3. Perform a lookup on the Connection Factory - ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("ConnectionFactory"); - - // Step 4.Create a JMS Connection - connection = cf.createConnection(); - - // Step 5. Create a JMS Session - Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - - // Step 6. Create a JMS Message Producer - MessageProducer producer = session.createProducer(queue); - - // Step 7. Create a Text Message - Message message = session.createMessage(); - - message.setStringProperty("AEROGEAR_ALERT", "Hello this is a notification from ActiveMQ"); - - producer.send(message); - - System.out.println("Sent message"); - - System.out.println("now check your mobile app and press enter"); - - System.in.read(); - } - 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/21bf4406/examples/jms/aerogear/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/jms/aerogear/src/main/resources/activemq/server0/broker.xml b/examples/jms/aerogear/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index 1095761..0000000 --- a/examples/jms/aerogear/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,77 +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> - - <!-- Acceptors --> - <acceptors> - <acceptor name="netty-acceptor">tcp://localhost:61616</acceptor> - </acceptors> - - <!-- We need to create a core queue for the JMS queue explicitly because the connector will be deployed - before the JMS queue is deployed, so the first time, it otherwise won't find the queue --> - <queues> - <queue name="jms.queue.exampleQueue"> - <address>jms.queue.exampleQueue</address> - </queue> - </queues> - - <connector-services> - <connector-service name="aerogear-connector"> - <factory-class>org.apache.activemq.artemis.integration.aerogear.AeroGearConnectorServiceFactory</factory-class> - <param key="endpoint" value="${endpoint}"/> - <param key="queue" value="jms.queue.exampleQueue"/> - <param key="application-id" value="${applicationid}"/> - <param key="master-secret" value="${mastersecret}"/> - </connector-service> - </connector-services> - - <!-- 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/aerogear/src/main/resources/jndi.properties ---------------------------------------------------------------------- diff --git a/examples/jms/aerogear/src/main/resources/jndi.properties b/examples/jms/aerogear/src/main/resources/jndi.properties deleted file mode 100644 index 93537c4..0000000 --- a/examples/jms/aerogear/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/application-layer-failover/pom.xml ---------------------------------------------------------------------- diff --git a/examples/jms/application-layer-failover/pom.xml b/examples/jms/application-layer-failover/pom.xml deleted file mode 100644 index b670d18..0000000 --- a/examples/jms/application-layer-failover/pom.xml +++ /dev/null @@ -1,102 +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>application-layer-failover</artifactId> - <packaging>jar</packaging> - <name>ActiveMQ Artemis JMS Application Layer Failover Example</name> - - <properties> - <activemq.basedir>${project.basedir}/../../..</activemq.basedir> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-cli</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.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> - <instance>${basedir}/target/server0</instance> - </configuration> - </execution> - <execution> - <id>create1</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <instance>${basedir}/target/server1</instance> - <portOffset>1</portOffset> - </configuration> - </execution> - <execution> - <id>runClient</id> - <goals> - <goal>runClient</goal> - </goals> - <configuration> - <clientClass>org.apache.activemq.artemis.jms.example.ApplicationLayerFailoverExample</clientClass> - <args> - <param>${basedir}/target/server0</param> - <param>${basedir}/target/server1</param> - </args> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.apache.activemq.examples.jms</groupId> - <artifactId>application-layer-failover</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - </plugin> - </plugins> - </build> - -</project> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/application-layer-failover/readme.html ---------------------------------------------------------------------- diff --git a/examples/jms/application-layer-failover/readme.html b/examples/jms/application-layer-failover/readme.html deleted file mode 100644 index 3a23b62..0000000 --- a/examples/jms/application-layer-failover/readme.html +++ /dev/null @@ -1,169 +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 Application-Layer Failover 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>Application-Layer Failover Example</h1> - - <pre>To run the example, simply type <b>mvn verify</b> from this directory. This example will always spawn and stop multiple servers.</pre> - - <p>ActiveMQ Artemis implements fully transparent <b>automatic</b> failover of connections from a live node to a backup node which requires - no special coding. This is described in a different example and requires server replication.</p> - <p>However, ActiveMQ Artemis also supports <b>Application-Layer</b> failover which is useful in the case where replication is not enabled.</p> - <p>With Application-Layer failover, it's up to the application to register a JMS ExceptionListener with ActiveMQ Artemis. - This listener will then be called by ActiveMQ Artemis in the event that connection failure is detected.</p> - <p>User code in the ExceptionListener can then recreate any JMS Connection, Session, etc on another node and the application - can continue.</p> - <p>Application-Layer failover is an alternative approach to High Availabilty (HA).</p> - <p>Application-Layer failover differs from automatic failover in that some client side coding is required in order - to implement this. Also, with Application-Layer failover, since the old Session object dies and a new is created, any uncommitted - work in the old Session will be lost, and any unacknowledged messages might be redelivered.</p> - <p>For more information on ActiveMQ Artemis failover and HA, and clustering in general, please see the clustering - section of the user manual.</p> - - <h2>Example step-by-step</h2> - <p>In this example, the live server is server 1, which will failover onto server 0.</p> - <p>The connection will initially be created to server1, server 1 will crash, and the client will carry on - on server 0, the new server. With Application-Layer failover the node that is failed over onto, does not need to - be specially configured as a backup server, it can be any node.</p> - - <ol> - <li> We create our JMS Connection, Session, MessageProducer and MessageConsumer on server 1</li> - <pre class="prettyprint"> - <code>createJMSObjects(1);</code> - </pre> - - <li>We set a JMS ExceptionListener on the connection. On failure this will be called and the connection, - session, etc. will be manually recreated on the backup node.</li> - <pre class="prettyprint"> - <code>connection.setExceptionListener(new ExampleListener());</code> - </pre> - - <li>We send some messages to server 1, the live server.</li> - <pre class="prettyprint"> - <code> - final int numMessages = 10; - - for (int i = 0; i < numMessages; i++) - { - TextMessage message = session.createTextMessage("This is text message " + i); - - producer.send(message); - - System.out.println("Sent message: " + message.getText()); - } - </code> - </pre> - - <li>We consume those messages on server 1.</li> - <pre class="prettyprint"> - <code> - for (int i = 0; i < numMessages; i++) - { - TextMessage message0 = (TextMessage)consumer.receive(5000); - - System.out.println("Got message: " + message0.getText()); - } - </code> - </pre> - - <li>We now cause server 1, the live server to crash. After a little while the connection's - ExceptionListener will register the failure and reconnection will occur.</li> - <pre class="prettyprint"> - <code>killServer(1);</code> - </pre> - - <li>The connection's ExceptionListener gets called, and we lookup the JMS objects and - recreate the connection, session, etc on the other node 0.</li> - <pre class="prettyprint"> - <code> - private class ExampleListener implements ExceptionListener - { - public void onException(JMSException exception) - { - try - { - // Close the old resources - - closeResources(); - - // Create new JMS objects on the backup server - - createJMSObjects(0); - - failoverLatch.countDown(); - } - catch (Exception e) - { - System.err.println("Failed to handle failover"); - - e.printStackTrace(); - } - } - } - </code> - </pre> - - <li>We are now connected to the other node. We now send some more messages.</li> - <pre class="prettyprint"> - <code> - for (int i = numMessages; i < numMessages * 2; i++) - { - TextMessage message = session.createTextMessage("This is text message " + i); - - producer.send(message); - - System.out.println("Sent message: " + message.getText()); - } - </code> - </pre> - - <li>And consume them.</li> - <pre class="prettyprint"> - <code> - for (int i = 0; i < numMessages; i++) - { - TextMessage message0 = (TextMessage)consumer.receive(5000); - - System.out.println("Got message: " + message0.getText()); - } - </code> - </pre> - - - <li>And finally (no pun intended), <b>always</b> remember to close your 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 - { - closeResources(); - } - </code> - </pre> - - </ol> - </body> -</html> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/application-layer-failover/src/main/java/org/apache/activemq/artemis/jms/example/ApplicationLayerFailoverExample.java ---------------------------------------------------------------------- diff --git a/examples/jms/application-layer-failover/src/main/java/org/apache/activemq/artemis/jms/example/ApplicationLayerFailoverExample.java b/examples/jms/application-layer-failover/src/main/java/org/apache/activemq/artemis/jms/example/ApplicationLayerFailoverExample.java deleted file mode 100644 index 2d0dc0c..0000000 --- a/examples/jms/application-layer-failover/src/main/java/org/apache/activemq/artemis/jms/example/ApplicationLayerFailoverExample.java +++ /dev/null @@ -1,221 +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.ExceptionListener; -import javax.jms.JMSException; -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 javax.naming.NamingException; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; -import org.apache.activemq.artemis.util.ServerUtil; - -/** - * A simple example that demonstrates application-layer failover of the JMS connection from one node to another - * when the live server crashes - */ -public class ApplicationLayerFailoverExample { - - private static InitialContext initialContext; - - private static Connection connection; - - private static Session session; - - private static MessageConsumer consumer; - - private static MessageProducer producer; - - private static final CountDownLatch failoverLatch = new CountDownLatch(1); - - private static Process server0; - - private static Process server1; - - public static void main(final String[] args) throws Exception { - try { - server0 = ServerUtil.startServer(args[0], ApplicationLayerFailoverExample.class.getSimpleName() + "0", 0, 5000); - server1 = ServerUtil.startServer(args[1], ApplicationLayerFailoverExample.class.getSimpleName() + "1", 1, 5000); - - // Step 1. We create our JMS Connection, Session, MessageProducer and MessageConsumer on server 1. - createJMSObjects(0); - - // Step 2. We set a JMS ExceptionListener on the connection. On failure this will be called and the connection, - // session, etc. will be then recreated on the backup node. - connection.setExceptionListener(new ExampleListener()); - - System.out.println("The initial JMS objects have been created, and the ExceptionListener set"); - - // Step 3. We send some messages to server 1, the live server - - final int numMessages = 10; - - for (int i = 0; i < numMessages; i++) { - TextMessage message = session.createTextMessage("This is text message " + i); - - producer.send(message); - - System.out.println("Sent message: " + message.getText()); - } - - // Step 4. We consume those messages on server 1. - - for (int i = 0; i < numMessages; i++) { - TextMessage message0 = (TextMessage) consumer.receive(5000); - - System.out.println("Got message: " + message0.getText()); - } - - // Step 5. We now cause server 1, the live server to crash. After a little while the connection's - // ExceptionListener will register the failure and reconnection will occur. - - System.out.println("Killing the server"); - - ServerUtil.killServer(server0); - - // Step 6. Wait for the client side to register the failure and reconnect - - boolean ok = failoverLatch.await(5000, TimeUnit.MILLISECONDS); - - System.out.println("Reconnection has occurred. Now sending more messages."); - - // Step 8. We now send some more messages - - for (int i = numMessages; i < numMessages * 2; i++) { - TextMessage message = session.createTextMessage("This is text message " + i); - - producer.send(message); - - System.out.println("Sent message: " + message.getText()); - } - - // Step 9. And consume them. - - for (int i = 0; i < numMessages; i++) { - TextMessage message0 = (TextMessage) consumer.receive(5000); - - System.out.println("Got message: " + message0.getText()); - } - } - catch (Throwable t) { - t.printStackTrace(); - } - finally { - // Step 14. Be sure to close our resources! - closeResources(); - ServerUtil.killServer(server0); - ServerUtil.killServer(server1); - } - } - - private static void createJMSObjects(final int server) throws Exception { - // Step 1. Instantiate a JMS Connection Factory object from JNDI on server 1 - ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://127.0.0.1:" + (61616 + server)); - - // Step 2. We create a JMS Connection connection - connection = connectionFactory.createConnection(); - - // Step 3. We start the connection to ensure delivery occurs - connection.start(); - - // Step 4. We create a JMS Session - session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - - // Step 5. Look-up the JMS Queue object from JNDI - Queue queue = session.createQueue("exampleQueue"); - - // Step 6. We create a JMS MessageConsumer object - consumer = session.createConsumer(queue); - - // Step 7. We create a JMS MessageProducer object - producer = session.createProducer(queue); - } - - private static void closeResources() { - if (initialContext != null) { - try { - initialContext.close(); - } - catch (NamingException e) { - e.printStackTrace(); - } - } - - if (connection != null) { - try { - connection.close(); - } - catch (JMSException e) { - e.printStackTrace(); - } - } - } - - private static class ExampleListener implements ExceptionListener { - - public void onException(final JMSException exception) { - try { - connection.close(); - } - catch (JMSException e) { - //ignore - } - for (int i = 0; i < 10; i++) { - try { - // Step 7. The ExceptionListener gets called and we recreate the JMS objects on the new node - - System.out.println("Connection failure has been detected on a the client."); - - // Close the old resources - - // closeResources(); - - System.out.println("The old resources have been closed."); - - // Create new JMS objects on the backup server - - createJMSObjects(1); - - System.out.println("The new resources have been created."); - - failoverLatch.countDown(); - - return; - } - catch (Exception e) { - System.out.println("Failed to handle failover, trying again."); - try { - Thread.sleep(500); - } - catch (InterruptedException e1) { - //ignored - } - } - } - System.out.println("tried 10 times to reconnect, giving up"); - } - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/artemis-ra-rar/pom.xml ---------------------------------------------------------------------- diff --git a/examples/jms/artemis-ra-rar/pom.xml b/examples/jms/artemis-ra-rar/pom.xml deleted file mode 100644 index 7f40bd7..0000000 --- a/examples/jms/artemis-ra-rar/pom.xml +++ /dev/null @@ -1,101 +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>artemis-rar</artifactId> - <packaging>rar</packaging> - <name>ActiveMQ Artemis JMS RA</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> - <exclusions> - <exclusion> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-core-client</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-jms-client</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>geronimo-jms_2.0_spec</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>geronimo-ejb_3.0_spec</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-ra</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-jms-server</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-core-client</artifactId> - <version>${project.version}</version> - <exclusions> - <exclusion> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-core-client</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>io.netty</groupId> - <artifactId>netty-all</artifactId> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-rar-plugin</artifactId> - <configuration> - <raXmlFile>src/main/resources/ra.xml</raXmlFile> - </configuration> - </plugin> - </plugins> - </build> - -</project> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/artemis-ra-rar/src/main/resources/ra.xml ---------------------------------------------------------------------- diff --git a/examples/jms/artemis-ra-rar/src/main/resources/ra.xml b/examples/jms/artemis-ra-rar/src/main/resources/ra.xml deleted file mode 100644 index db571a3..0000000 --- a/examples/jms/artemis-ra-rar/src/main/resources/ra.xml +++ /dev/null @@ -1,308 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- $Id: ra.xml 76819 2008-08-08 11:04:20Z jesper.pedersen $ --> - -<connector xmlns="http://java.sun.com/xml/ns/j2ee" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee - http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd" - version="1.5"> - - <description>ActiveMQ Artemis 2.0 Resource Adapter</description> - <display-name>ActiveMQ Artemis 2.0 Resource Adapter</display-name> - - <vendor-name>Apache Software Foundation</vendor-name> - <eis-type>JMS 1.1 Server</eis-type> - <resourceadapter-version>1.0</resourceadapter-version> - - <license> - <description> - 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. - </description> - <license-required>true</license-required> - </license> - - <resourceadapter> - <resourceadapter-class>org.apache.activemq.artemis.ra.ActiveMQResourceAdapter</resourceadapter-class> - <config-property> - <description> - The transport type. Multiple connectors can be configured by using a comma separated list, - i.e. org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory,org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory. - </description> - <config-property-name>ConnectorClassName</config-property-name> - <config-property-type>java.lang.String</config-property-type> - <config-property-value>org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory</config-property-value> - </config-property> - <config-property> - <description>The transport configuration. These values must be in the form of key=val;key=val;, - if multiple connectors are used then each set must be separated by a comma i.e. host=host1;port=61616,host=host2;port=61617. - Each set of params maps to the connector classname specified. - </description> - <config-property-name>ConnectionParameters</config-property-name> - <config-property-type>java.lang.String</config-property-type> - <config-property-value>server-id=0</config-property-value> - </config-property> - <!-- - <config-property> - <description>Does we support HA</description> - <config-property-name>HA</config-property-name> - <config-property-type>java.lang.Boolean</config-property-type> - <config-property-value>false</config-property-value> - </config-property> - <config-property> - <description>The method to use for locating the transactionmanager</description> - <config-property-name>TransactionManagerLocatorMethod</config-property-name> - <config-property-type>java.lang.String</config-property-type> - <config-property-value>getTm</config-property-value> - </config-property> - <config-property> - <description>Use A local Transaction instead of XA?</description> - <config-property-name>UseLocalTx</config-property-name> - <config-property-type>java.lang.Boolean</config-property-type> - <config-property-value>false</config-property-value> - </config-property> - <config-property> - <description>The user name used to login to the JMS server</description> - <config-property-name>UserName</config-property-name> - <config-property-type>java.lang.String</config-property-type> - <config-property-value></config-property-value> - </config-property> - <config-property> - <description>The password used to login to the JMS server</description> - <config-property-name>Password</config-property-name> - <config-property-type>java.lang.String</config-property-type> - <config-property-value></config-property-value> - </config-property> - <config-property> - <description>The jndi params to use to look up the jms resources if local jndi is not to be used</description> - <config-property-name>JndiParams</config-property-name> - <config-property-type>java.lang.String</config-property-type> - <config-property-value>java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory;java.naming.provider.url=jnp://localhost:1199;java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces</config-property-value> - </config-property> - <config-property> - <description>The jGroups File name</description> - <config-property-name>JgroupsFile</config-property-name> - <config-property-type>java.lang.String</config-property-type> - <config-property-value>jgroups.xml</config-property-value> - </config-property> - <config-property> - <description>The name of the channel used on this configuration</description> - <config-property-name>JgroupsChannelName</config-property-name> - <config-property-type>java.lang.Integer</config-property-type> - <config-property-value>my-channel</config-property-value> - </config-property> - <config-property> - <description>The discovery group address</description> - <config-property-name>DiscoveryAddress</config-property-name> - <config-property-type>java.lang.String</config-property-type> - <config-property-value></config-property-value> - </config-property> - <config-property> - <description>The discovery group port</description> - <config-property-name>DiscoveryPort</config-property-name> - <config-property-type>java.lang.Integer</config-property-type> - <config-property-value></config-property-value> - </config-property> - <config-property> - <description>The discovery refresh timeout</description> - <config-property-name>DiscoveryRefreshTimeout</config-property-name> - <config-property-type>java.lang.Long</config-property-type> - <config-property-value></config-property-value> - </config-property> - <config-property> - <description>The discovery initial wait timeout</description> - <config-property-name>DiscoveryInitialWaitTimeout</config-property-name> - <config-property-type>java.lang.Long</config-property-type> - <config-property-value></config-property-value> - </config-property> - <config-property> - <description>The load balancing policy class name</description> - <config-property-name>LoadBalancingPolicyClassName</config-property-name> - <config-property-type>java.lang.String</config-property-type> - <config-property-value></config-property-value> - </config-property> - <config-property> - <description>The client failure check period</description> - <config-property-name>ClientFailureCheckPeriod</config-property-name> - <config-property-type>java.lang.Long</config-property-type> - <config-property-value></config-property-value> - </config-property> - <config-property> - <description>The connection TTL</description> - <config-property-name>ConnectionTTL</config-property-name> - <config-property-type>java.lang.Long</config-property-type> - <config-property-value></config-property-value> - </config-property> - <config-property> - <description>The call timeout</description> - <config-property-name>CallTimeout</config-property-name> - <config-property-type>java.lang.Long</config-property-type> - <config-property-value></config-property-value> - </config-property> - <config-property> - <description>The dups ok batch size</description> - <config-property-name>DupsOKBatchSize</config-property-name> - <config-property-type>java.lang.Integer</config-property-type> - <config-property-value></config-property-value> - </config-property> - <config-property> - <description>The transaction batch size</description> - <config-property-name>TransactionBatchSize</config-property-name> - <config-property-type>java.lang.Integer</config-property-type> - <config-property-value></config-property-value> - </config-property> - <config-property> - <description>The consumer window size</description> - <config-property-name>ConsumerWindowSize</config-property-name> - <config-property-type>java.lang.Integer</config-property-type> - <config-property-value></config-property-value> - </config-property> - <config-property> - <description>The consumer max rate</description> - <config-property-name>ConsumerMaxRate</config-property-name> - <config-property-type>java.lang.Integer</config-property-type> - <config-property-value></config-property-value> - </config-property> - <config-property> - <description>The confirmation window size</description> - <config-property-name>ConfirmationWindowSize</config-property-name> - <config-property-type>java.lang.Integer</config-property-type> - <config-property-value></config-property-value> - </config-property> - <config-property> - <description>The producer max rate</description> - <config-property-name>ProducerMaxRate</config-property-name> - <config-property-type>java.lang.Integer</config-property-type> - <config-property-value></config-property-value> - </config-property> - <config-property> - <description>The min large message size</description> - <config-property-name>MinLargeMessageSize</config-property-name> - <config-property-type>java.lang.Integer</config-property-type> - <config-property-value></config-property-value> - </config-property> - <config-property> - <description>The block on acknowledge</description> - <config-property-name>BlockOnAcknowledge</config-property-name> - <config-property-type>java.lang.Boolean</config-property-type> - <config-property-value></config-property-value> - </config-property> - <config-property> - <description>The block on non durable send</description> - <config-property-name>BlockOnNonDurableSend</config-property-name> - <config-property-type>java.lang.Boolean</config-property-type> - <config-property-value></config-property-value> - </config-property> - <config-property> - <description>The block on durable send</description> - <config-property-name>BlockOnDurableSend</config-property-name> - <config-property-type>java.lang.Boolean</config-property-type> - <config-property-value></config-property-value> - </config-property> - <config-property> - <description>The auto group</description> - <config-property-name>AutoGroup</config-property-name> - <config-property-type>java.lang.Boolean</config-property-type> - <config-property-value></config-property-value> - </config-property> - <config-property> - <description>The max connections</description> - <config-property-type>java.lang.Integer</config-property-type> - <config-property-value></config-property-value> - </config-property> - <config-property> - <description>The pre acknowledge</description> - <config-property-name>PreAcknowledge</config-property-name> - <config-property-type>java.lang.Boolean</config-property-type> - <config-property-value></config-property-value> - </config-property> - <config-property> - <description>The retry interval</description> - <config-property-name>RetryInterval</config-property-name> - <config-property-type>java.lang.Long</config-property-type> - <config-property-value></config-property-value> - </config-property> - <config-property> - <description>The retry interval multiplier</description> - <config-property-name>RetryIntervalMultiplier</config-property-name> - <config-property-type>java.lang.Double</config-property-type> - <config-property-value></config-property-value> - </config-property> - <config-property> - <description>The client id</description> - <config-property-name>ClientID</config-property-name> - <config-property-type>java.lang.String</config-property-type> - <config-property-value></config-property-value> - </config-property> - <config-property> - <description>Whether the password is cleartext or encrypted, default false</description> - <config-property-name>UseMaskedPassword</config-property-name> - <config-property-type>java.lang.Boolean</config-property-type> - <config-property-value></config-property-value> - </config-property> - <config-property> - <description>The class definition (full qualified name and its properties) used to encrypt the password</description> - <config-property-name>PasswordCodec</config-property-name> - <config-property-type>java.lang.String</config-property-type> - <config-property-value>org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec;key=clusterpassword;algorithm=something</config-property-value> - </config-property>--> - - <outbound-resourceadapter> - <connection-definition> - <managedconnectionfactory-class>org.apache.activemq.artemis.ra.ActiveMQRAManagedConnectionFactory</managedconnectionfactory-class> - - <config-property> - <description>The default session type</description> - <config-property-name>SessionDefaultType</config-property-name> - <config-property-type>java.lang.String</config-property-type> - <config-property-value>javax.jms.Queue</config-property-value> - </config-property> - <config-property> - <description>Try to obtain a lock within specified number of seconds; less than or equal to 0 disable this functionality</description> - <config-property-name>UseTryLock</config-property-name> - <config-property-type>java.lang.Integer</config-property-type> - <config-property-value>0</config-property-value> - </config-property> - - <connectionfactory-interface>org.apache.activemq.artemis.ra.ActiveMQRAConnectionFactory</connectionfactory-interface> - <connectionfactory-impl-class>org.apache.activemq.artemis.ra.ActiveMQRAConnectionFactoryImpl</connectionfactory-impl-class> - <connection-interface>javax.jms.Session</connection-interface> - <connection-impl-class>org.apache.activemq.artemis.ra.ActiveMQRASession</connection-impl-class> - </connection-definition> - <transaction-support>XATransaction</transaction-support> - <authentication-mechanism> - <authentication-mechanism-type>BasicPassword</authentication-mechanism-type> - <credential-interface>javax.resource.spi.security.PasswordCredential</credential-interface> - </authentication-mechanism> - <reauthentication-support>false</reauthentication-support> - </outbound-resourceadapter> - - <inbound-resourceadapter> - <messageadapter> - <messagelistener> - <messagelistener-type>javax.jms.MessageListener</messagelistener-type> - <activationspec> - <activationspec-class>org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec</activationspec-class> - <required-config-property> - <config-property-name>destination</config-property-name> - </required-config-property> - </activationspec> - </messagelistener> - </messageadapter> - </inbound-resourceadapter> - - </resourceadapter> -</connector> http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21bf4406/examples/jms/bridge/pom.xml ---------------------------------------------------------------------- diff --git a/examples/jms/bridge/pom.xml b/examples/jms/bridge/pom.xml deleted file mode 100644 index 8c835de..0000000 --- a/examples/jms/bridge/pom.xml +++ /dev/null @@ -1,176 +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>core-bridge</artifactId> - <packaging>jar</packaging> - <name>ActiveMQ Artemis Core Bridge Example</name> - - <properties> - <activemq.basedir>${project.basedir}/../../..</activemq.basedir> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>artemis-server</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>geronimo-jms_2.0_spec</artifactId> - </dependency> - </dependencies> - - <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> - <libList> - <!-- For the transformer --> - <arg>org.apache.activemq.examples.jms:core-bridge:${project.version}</arg> - </libList> - <ignore>${noServer}</ignore> - <instance>${basedir}/target/server0</instance> - <configuration>${basedir}/target/classes/activemq/server0</configuration> - </configuration> - </execution> - <execution> - <id>create1</id> - <goals> - <goal>create</goal> - </goals> - <configuration> - <libList> - <!-- For the transformer --> - <arg>org.apache.activemq.examples.jms:core-bridge:${project.version}</arg> - </libList> - <ignore>${noServer}</ignore> - <instance>${basedir}/target/server1</instance> - <configuration>${basedir}/target/classes/activemq/server1</configuration> - <portOffset>1</portOffset> - </configuration> - </execution> - <execution> - <id>start0</id> - <goals> - <goal>cli</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <spawn>true</spawn> - <location>${basedir}/target/server0</location> - <testURI>tcp://localhost:61616</testURI> - <args> - <param>run</param> - </args> - <name>server0</name> - </configuration> - </execution> - <execution> - <id>start1</id> - <goals> - <goal>cli</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <spawn>true</spawn> - <location>${basedir}/target/server1</location> - <testURI>tcp://localhost:61617</testURI> - <args> - <param>run</param> - </args> - <name>server1</name> - </configuration> - </execution> - <execution> - <id>runClient</id> - <goals> - <goal>runClient</goal> - </goals> - <configuration> - <clientClass>org.apache.activemq.artemis.jms.example.BridgeExample</clientClass> - </configuration> - </execution> - <execution> - <id>stop0</id> - <goals> - <goal>cli</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <location>${basedir}/target/server0</location> - <args> - <param>stop</param> - </args> - </configuration> - </execution> - <execution> - <id>stop1</id> - <goals> - <goal>cli</goal> - </goals> - <configuration> - <ignore>${noServer}</ignore> - <location>${basedir}/target/server1</location> - <args> - <param>stop</param> - </args> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.apache.activemq.examples.jms</groupId> - <artifactId>core-bridge</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - </plugin> - </plugins> - </build> - -</project>
