You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ce...@apache.org on 2013/01/25 23:06:16 UTC

svn commit: r1438738 [2/2] - in /activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire: ./ advanced-scenarios/ advanced-scenarios/jms-example-composite-destinations/ advanced-scenarios/jms-example-composite-destinations/src/ a...

Copied: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-topic/readme.md (from r1438023, activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/jms-example-topic/readme.md)
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-topic/readme.md?p2=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-topic/readme.md&p1=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/jms-example-topic/readme.md&r1=1438023&r2=1438738&rev=1438738&view=diff
==============================================================================
    (empty)

Copied: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-topic/src/main/java/example/topic/Publisher.java (from r1438023, activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/jms-example-topic/src/main/java/example/topic/Publisher.java)
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-topic/src/main/java/example/topic/Publisher.java?p2=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-topic/src/main/java/example/topic/Publisher.java&p1=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/jms-example-topic/src/main/java/example/topic/Publisher.java&r1=1438023&r2=1438738&rev=1438738&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/jms-example-topic/src/main/java/example/topic/Publisher.java (original)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-topic/src/main/java/example/topic/Publisher.java Fri Jan 25 22:06:13 2013
@@ -16,7 +16,6 @@
  */
 package example.topic;
 
-import example.util.Util;
 import org.apache.activemq.ActiveMQConnectionFactory;
 
 import javax.jms.*;
@@ -25,16 +24,17 @@ import javax.jms.*;
  * @author <a href="http://www.christianposta.com/blog">Christian Posta</a>
  */
 public class Publisher {
-    private static final String BROKER_HOST = "tcp://localhost:%d";
-    private static final int BROKER_PORT = Util.getBrokerPort();
-    private static final String BROKER_URL = String.format(BROKER_HOST, BROKER_PORT);
+    private static final String BROKER_URL = "tcp://localhost:61613";
     private static final Boolean NON_TRANSACTED = false;
     private static final int NUM_MESSAGES_TO_SEND = 100;
     private static final long DELAY = 100;
 
     public static void main(String[] args) {
-
-        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("admin", "password", BROKER_URL);
+        String url = BROKER_URL;
+        if (args.length > 0) {
+            url = args[0].trim();
+        }
+        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("admin", "password", url);
         Connection connection = null;
 
         try {

Copied: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-topic/src/main/java/example/topic/Subscriber.java (from r1438023, activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/jms-example-topic/src/main/java/example/topic/Subscriber.java)
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-topic/src/main/java/example/topic/Subscriber.java?p2=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-topic/src/main/java/example/topic/Subscriber.java&p1=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/jms-example-topic/src/main/java/example/topic/Subscriber.java&r1=1438023&r2=1438738&rev=1438738&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/jms-example-topic/src/main/java/example/topic/Subscriber.java (original)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-topic/src/main/java/example/topic/Subscriber.java Fri Jan 25 22:06:13 2013
@@ -16,7 +16,6 @@
  */
 package example.topic;
 
-import example.util.Util;
 import org.apache.activemq.ActiveMQConnectionFactory;
 
 import javax.jms.*;
@@ -26,10 +25,8 @@ import java.util.concurrent.CountDownLat
  * @author <a href="http://www.christianposta.com/blog">Christian Posta</a>
  */
 public class Subscriber implements MessageListener {
+    private static final String BROKER_URL = "tcp://localhost:61613";
 
-    private static final String BROKER_HOST = "tcp://localhost:%d";
-    private static final int BROKER_PORT = Util.getBrokerPort();
-    private static final String BROKER_URL = String.format(BROKER_HOST, BROKER_PORT);
     private static final Boolean NON_TRANSACTED = false;
 
 
@@ -39,8 +36,12 @@ public class Subscriber implements Messa
     }
 
     public static void main(String[] args) {
+        String url = BROKER_URL;
+        if (args.length > 0) {
+            url = args[0].trim();
+        }
         System.out.println("\nWaiting to receive messages... Either waiting for END message or press Ctrl+C to exit");
-        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("admin", "password", BROKER_URL);
+        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("admin", "password", url);
         Connection connection = null;
         final CountDownLatch latch = new CountDownLatch(1);
 

Copied: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-topic/src/main/resources/log4j.properties (from r1438023, activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/jms-example-topic/src/main/resources/log4j.properties)
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-topic/src/main/resources/log4j.properties?p2=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-topic/src/main/resources/log4j.properties&p1=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/jms-example-topic/src/main/resources/log4j.properties&r1=1438023&r2=1438738&rev=1438738&view=diff
==============================================================================
    (empty)

Copied: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-transaction/pom.xml (from r1438023, activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/jms-example-transaction/pom.xml)
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-transaction/pom.xml?p2=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-transaction/pom.xml&p1=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/jms-example-transaction/pom.xml&r1=1438023&r2=1438738&rev=1438738&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/jms-example-transaction/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-transaction/pom.xml Fri Jan 25 22:06:13 2013
@@ -22,7 +22,7 @@
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <parent>
-        <artifactId>openwire-example</artifactId>
+        <artifactId>advanced-openwire-example</artifactId>
         <groupId>example</groupId>
         <version>0.1-SNAPSHOT</version>
     </parent>
@@ -30,14 +30,6 @@
 
     <artifactId>jms-example-transaction</artifactId>
 
-    <dependencies>
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>jms-example-util</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-    </dependencies>
-
     <profiles>
         <profile>
             <id>client</id>

Copied: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-transaction/readme.md (from r1438023, activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/jms-example-transaction/readme.md)
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-transaction/readme.md?p2=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-transaction/readme.md&p1=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/jms-example-transaction/readme.md&r1=1438023&r2=1438738&rev=1438738&view=diff
==============================================================================
    (empty)

Copied: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-transaction/src/main/java/example/transaction/Client.java (from r1438023, activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/jms-example-transaction/src/main/java/example/transaction/Client.java)
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-transaction/src/main/java/example/transaction/Client.java?p2=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-transaction/src/main/java/example/transaction/Client.java&p1=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/jms-example-transaction/src/main/java/example/transaction/Client.java&r1=1438023&r2=1438738&rev=1438738&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/jms-example-transaction/src/main/java/example/transaction/Client.java (original)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-transaction/src/main/java/example/transaction/Client.java Fri Jan 25 22:06:13 2013
@@ -16,7 +16,6 @@
  */
 package example.transaction;
 
-import example.util.Util;
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.command.ActiveMQTopic;
 
@@ -27,17 +26,18 @@ import java.util.Scanner;
  * @author <a href="http://www.christianposta.com/blog">Christian Posta</a>
  */
 public class Client {
-    private static final String BROKER_HOST = "tcp://localhost:%d";
-    private static final int BROKER_PORT = Util.getBrokerPort();
-    private static final String BROKER_URL = String.format(BROKER_HOST, BROKER_PORT);
+    private static final String BROKER_URL = "tcp://localhost:61613";
 
     // this is set to true
     private static final Boolean TRANSACTED = true;
     private static final Boolean NON_TRANSACTED = false;
 
     public static void main(String[] args) {
-
-        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("admin", "password", BROKER_URL);
+        String url = BROKER_URL;
+        if (args.length > 0) {
+            url = args[0].trim();
+        }
+        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("admin", "password", url);
         Connection connection = null;
 
         try {

Copied: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-wildcard-consumer/pom.xml (from r1438023, activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/jms-example-wildcard-consumer/pom.xml)
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-wildcard-consumer/pom.xml?p2=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-wildcard-consumer/pom.xml&p1=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/jms-example-wildcard-consumer/pom.xml&r1=1438023&r2=1438738&rev=1438738&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/jms-example-wildcard-consumer/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-wildcard-consumer/pom.xml Fri Jan 25 22:06:13 2013
@@ -19,7 +19,7 @@
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <parent>
-        <artifactId>openwire-example</artifactId>
+        <artifactId>advanced-openwire-example</artifactId>
         <groupId>example</groupId>
         <version>0.1-SNAPSHOT</version>
     </parent>
@@ -27,14 +27,6 @@
 
     <artifactId>jms-example-wildcard-consumer</artifactId>
 
-    <dependencies>
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>jms-example-util</artifactId>
-            <version>${project.version}</version>
-        </dependency>
-    </dependencies>
-
     <profiles>
         <profile>
             <id>consumer</id>

Copied: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-wildcard-consumer/readme.md (from r1438023, activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/jms-example-wildcard-consumer/readme.md)
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-wildcard-consumer/readme.md?p2=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-wildcard-consumer/readme.md&p1=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/jms-example-wildcard-consumer/readme.md&r1=1438023&r2=1438738&rev=1438738&view=diff
==============================================================================
    (empty)

Copied: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-wildcard-consumer/src/main/java/example/wildcard/Client.java (from r1438023, activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/jms-example-wildcard-consumer/src/main/java/example/wildcard/Client.java)
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-wildcard-consumer/src/main/java/example/wildcard/Client.java?p2=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-wildcard-consumer/src/main/java/example/wildcard/Client.java&p1=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/jms-example-wildcard-consumer/src/main/java/example/wildcard/Client.java&r1=1438023&r2=1438738&rev=1438738&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/jms-example-wildcard-consumer/src/main/java/example/wildcard/Client.java (original)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/jms-example-wildcard-consumer/src/main/java/example/wildcard/Client.java Fri Jan 25 22:06:13 2013
@@ -16,7 +16,6 @@
  */
 package example.wildcard;
 
-import example.util.Util;
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.command.ActiveMQTopic;
 
@@ -28,13 +27,14 @@ import java.util.Scanner;
  */
 public class Client {
     private static final Boolean NON_TRANSACTED = false;
-    private static final String BROKER_HOST = "tcp://localhost:%d";
-    private static final int BROKER_PORT = Util.getBrokerPort();
-    private static final String BROKER_URL = String.format(BROKER_HOST, BROKER_PORT);
+    private static final String BROKER_URL = "tcp://localhost:61613";
 
     public static void main(String[] args) {
-
-        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("admin", "password", BROKER_URL);
+        String url = BROKER_URL;
+        if (args.length > 0) {
+            url = args[0].trim();
+        }
+        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("admin", "password", url);
         Connection connection = null;
 
         try {

Copied: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/pom.xml (from r1438023, activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/pom.xml)
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/pom.xml?p2=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/pom.xml&p1=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/pom.xml&r1=1438023&r2=1438738&rev=1438738&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/pom.xml Fri Jan 25 22:06:13 2013
@@ -21,7 +21,7 @@
     <modelVersion>4.0.0</modelVersion>
 
     <groupId>example</groupId>
-    <artifactId>openwire-example</artifactId>
+    <artifactId>advanced-openwire-example</artifactId>
     <packaging>pom</packaging>
     <version>0.1-SNAPSHOT</version>
     <modules>
@@ -29,7 +29,6 @@
         <module>jms-example-topic</module>
         <module>jms-example-exclusive-consumer</module>
         <module>jms-example-transaction</module>
-        <module>jms-example-util</module>
         <module>jms-example-durable-sub</module>
         <module>jms-example-wildcard-consumer</module>
         <module>jms-example-temp-destinations</module>
@@ -42,7 +41,7 @@
     <description>Apollo OpenWire Java Examples</description>
 
     <properties>
-        <activemq.version>5.6.0</activemq.version>
+        <activemq.version>5.7.0</activemq.version>
     </properties>
 
     <repositories>

Copied: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/readme.md (from r1438023, activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/readme.md)
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/readme.md?p2=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/advanced-scenarios/readme.md&p1=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/readme.md&r1=1438023&r2=1438738&rev=1438738&view=diff
==============================================================================
    (empty)

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/java/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/java/pom.xml?rev=1438738&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/java/pom.xml (added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/java/pom.xml Fri Jan 25 22:06:13 2013
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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>
+  
+  <groupId>example</groupId>
+  <artifactId>openwire-example</artifactId>
+  <version>0.1-SNAPSHOT</version>
+  
+  <name>example</name>
+  <description>Apollo Openwire Java Examples</description>
+
+  <repositories>
+    <repository>
+      <id>Fusesource Snapshots</id>
+      <url>http://repo.fusesource.com/nexus/content/repositories/snapshots</url>
+    </repository>
+  </repositories>
+    <properties>
+        <activemq.version>5.7.0</activemq.version>
+    </properties>
+  <dependencies>
+    
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-jms_1.1_spec</artifactId>
+      <version>1.1</version>
+    </dependency>
+      <dependency>
+          <groupId>org.apache.activemq</groupId>
+          <artifactId>activemq-core</artifactId>
+          <version>${activemq.version}</version>
+      </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.1</version>
+        <configuration>
+          <source>1.6</source>
+          <target>1.6</target>
+        </configuration>
+      </plugin>
+
+      <!-- include all the dependencies into the jar so it's easier to execute the example -->
+      <plugin>
+        <groupId>org.fusesource.mvnplugins</groupId>
+        <artifactId>maven-uberize-plugin</artifactId>
+        <version>1.14</version>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals><goal>uberize</goal></goals>
+          </execution>
+        </executions>
+      </plugin>
+      
+    </plugins>
+  </build>
+  
+</project>
+

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/java/readme.md
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/java/readme.md?rev=1438738&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/java/readme.md (added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/java/readme.md Fri Jan 25 22:06:13 2013
@@ -0,0 +1,32 @@
+## Overview
+
+This is an example of how use the Java JMS api with Apollo.
+
+## Prereqs
+
+- Install Java SDK
+- Install [Maven](http://maven.apache.org/download.html) 
+
+## Building
+
+Run:
+
+    mvn install
+
+## Running the Examples
+
+In one terminal window run:
+
+    java -cp target/openwire-example-0.1-SNAPSHOT.jar example.Listener
+
+In another terminal window run:
+
+    java -cp target/openwire-example-0.1-SNAPSHOT.jar example.Publisher
+
+You can control to which server the examples try to connect to by
+setting the following environment variables: 
+
+* `APOLLO_HOST`
+* `APOLLO_PORT`
+* `APOLLO_USER`
+* `APOLLO_PASSWORD`

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/java/src/main/java/example/Listener.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/java/src/main/java/example/Listener.java?rev=1438738&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/java/src/main/java/example/Listener.java (added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/java/src/main/java/example/Listener.java Fri Jan 25 22:06:13 2013
@@ -0,0 +1,88 @@
+/**
+ * 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 example;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.command.ActiveMQTopic;
+
+import javax.jms.*;
+
+class Listener {
+
+    public static void main(String []args) throws JMSException {
+
+        String user = env("APOLLO_USER", "admin");
+        String password = env("APOLLO_PASSWORD", "password");
+        String host = env("APOLLO_HOST", "localhost");
+        int port = Integer.parseInt(env("APOLLO_PORT", "61613"));
+        String destination = arg(args, 0, "event");
+
+        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://" + host + ":" + port);
+
+        Connection connection = factory.createConnection(user, password);
+        connection.start();
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        Destination dest = new ActiveMQTopic(destination);
+
+        MessageConsumer consumer = session.createConsumer(dest);
+        long start = System.currentTimeMillis();
+        long count = 1;
+        System.out.println("Waiting for messages...");
+        while(true) {
+            Message msg = consumer.receive();
+            if( msg instanceof  TextMessage ) {
+                String body = ((TextMessage) msg).getText();
+                if( "SHUTDOWN".equals(body)) {
+                    long diff = System.currentTimeMillis() - start;
+                    System.out.println(String.format("Received %d in %.2f seconds", count, (1.0*diff/1000.0)));
+                    break;
+                } else {
+                    if( count != msg.getIntProperty("id") ) {
+                        System.out.println("mismatch: "+count+"!="+msg.getIntProperty("id"));
+                    }
+                    count = msg.getIntProperty("id");
+
+                    if( count == 0 ) {
+                        start = System.currentTimeMillis();
+                    }
+                    if( count % 1000 == 0 ) {
+                        System.out.println(String.format("Received %d messages.", count));
+                    }
+                    count ++;
+                }
+
+            } else {
+                System.out.println("Unexpected message type: "+msg.getClass());
+            }
+        }
+        connection.close();
+    }
+
+    private static String env(String key, String defaultValue) {
+        String rc = System.getenv(key);
+        if( rc== null )
+            return defaultValue;
+        return rc;
+    }
+
+    private static String arg(String []args, int index, String defaultValue) {
+        if( index < args.length )
+            return args[index];
+        else
+            return defaultValue;
+    }
+}
\ No newline at end of file

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/java/src/main/java/example/Publisher.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/java/src/main/java/example/Publisher.java?rev=1438738&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/java/src/main/java/example/Publisher.java (added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/openwire/java/src/main/java/example/Publisher.java Fri Jan 25 22:06:13 2013
@@ -0,0 +1,80 @@
+/**
+ * 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 example;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.command.ActiveMQTopic;
+
+import javax.jms.*;
+
+class Publisher {
+
+    public static void main(String []args) throws JMSException {
+
+        String user = env("APOLLO_USER", "admin");
+        String password = env("APOLLO_PASSWORD", "password");
+        String host = env("APOLLO_HOST", "localhost");
+        int port = Integer.parseInt(env("APOLLO_PORT", "61613"));
+        String destination = arg(args, 0, "event");
+
+        int messages = 10000;
+        int size = 256;
+
+        String DATA = "abcdefghijklmnopqrstuvwxyz";
+        String body = "";
+        for( int i=0; i < size; i ++) {
+            body += DATA.charAt(i%DATA.length());
+        }
+
+        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://" + host + ":" + port);
+
+        Connection connection = factory.createConnection(user, password);
+        connection.start();
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        Destination dest = new ActiveMQTopic(destination);
+        MessageProducer producer = session.createProducer(dest);
+        producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+        for( int i=1; i <= messages; i ++) {
+            TextMessage msg = session.createTextMessage(body);
+            msg.setIntProperty("id", i);
+            producer.send(msg);
+            if( (i % 1000) == 0) {
+                System.out.println(String.format("Sent %d messages", i));
+            }
+        }
+
+        producer.send(session.createTextMessage("SHUTDOWN"));
+        connection.close();
+
+    }
+
+    private static String env(String key, String defaultValue) {
+        String rc = System.getenv(key);
+        if( rc== null )
+            return defaultValue;
+        return rc;
+    }
+
+    private static String arg(String []args, int index, String defaultValue) {
+        if( index < args.length )
+            return args[index];
+        else
+            return defaultValue;
+    }
+
+}
\ No newline at end of file