brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [11/12] incubator-brooklyn git commit: brooklyn-example-simple-messaging-pubsub: add org.apache package prefix
Date Wed, 15 Jul 2015 23:09:55 GMT
brooklyn-example-simple-messaging-pubsub: add org.apache package prefix


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/f2792fa1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/f2792fa1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/f2792fa1

Branch: refs/heads/master
Commit: f2792fa18a7bfb58f42938cde6f6bbaed49dacec
Parents: 44d2dc1
Author: Ciprian Ciubotariu <cheepeero@gmx.net>
Authored: Wed Jul 15 11:11:14 2015 +0300
Committer: Ciprian Ciubotariu <cheepeero@gmx.net>
Committed: Wed Jul 15 18:47:01 2015 +0300

----------------------------------------------------------------------
 .../java/brooklyn/demo/KafkaClusterExample.java | 58 ---------------
 .../src/main/java/brooklyn/demo/Publish.java    | 71 ------------------
 .../demo/StandaloneQpidBrokerExample.java       | 73 -------------------
 .../src/main/java/brooklyn/demo/Subscribe.java  | 76 --------------------
 .../brooklyn/demo/KafkaClusterExample.java      | 58 +++++++++++++++
 .../java/org/apache/brooklyn/demo/Publish.java  | 71 ++++++++++++++++++
 .../demo/StandaloneQpidBrokerExample.java       | 73 +++++++++++++++++++
 .../org/apache/brooklyn/demo/Subscribe.java     | 76 ++++++++++++++++++++
 8 files changed, 278 insertions(+), 278 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f2792fa1/examples/simple-messaging-pubsub/src/main/java/brooklyn/demo/KafkaClusterExample.java
----------------------------------------------------------------------
diff --git a/examples/simple-messaging-pubsub/src/main/java/brooklyn/demo/KafkaClusterExample.java
b/examples/simple-messaging-pubsub/src/main/java/brooklyn/demo/KafkaClusterExample.java
deleted file mode 100644
index ec921c9..0000000
--- a/examples/simple-messaging-pubsub/src/main/java/brooklyn/demo/KafkaClusterExample.java
+++ /dev/null
@@ -1,58 +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 brooklyn.demo;
-
-import java.util.List;
-
-import brooklyn.entity.basic.ApplicationBuilder;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.messaging.kafka.KafkaCluster;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.launcher.BrooklynLauncher;
-import brooklyn.util.CommandLineUtil;
-
-import com.google.common.collect.Lists;
-
-/** Kafka Cluster Application */
-public class KafkaClusterExample extends ApplicationBuilder {
-
-    public static final String DEFAULT_LOCATION = "localhost";
-
-    /** Configure the application. */
-    protected void doBuild() {
-        addChild(EntitySpec.create(KafkaCluster.class)
-                .configure("startTimeout", 300) // 5 minutes
-                .configure("initialSize", 2));
-        // TODO set application display name?
-    }
-
-    public static void main(String[] argv) {
-        List<String> args = Lists.newArrayList(argv);
-        String port =  CommandLineUtil.getCommandLineOption(args, "--port", "8081+");
-        String location = CommandLineUtil.getCommandLineOption(args, "--location", DEFAULT_LOCATION);
-
-        BrooklynLauncher launcher = BrooklynLauncher.newInstance()
-                .application(new KafkaClusterExample().appDisplayName("Kafka cluster application"))
-                .webconsolePort(port)
-                .location(location)
-                .start();
-
-        Entities.dumpInfo(launcher.getApplications());
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f2792fa1/examples/simple-messaging-pubsub/src/main/java/brooklyn/demo/Publish.java
----------------------------------------------------------------------
diff --git a/examples/simple-messaging-pubsub/src/main/java/brooklyn/demo/Publish.java b/examples/simple-messaging-pubsub/src/main/java/brooklyn/demo/Publish.java
deleted file mode 100644
index 22c0a60..0000000
--- a/examples/simple-messaging-pubsub/src/main/java/brooklyn/demo/Publish.java
+++ /dev/null
@@ -1,71 +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 brooklyn.demo;
-
-import javax.jms.Connection;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.qpid.client.AMQConnectionFactory;
-import org.apache.qpid.configuration.ClientProperties;
-
-import com.google.common.base.Preconditions;
-import com.google.common.base.Throwables;
-
-/** Publishes messages to a queue on a Qpid broker at a given URL. */
-public class Publish {
-    public static final String QUEUE = "'amq.direct'/'testQueue'; { node: { type: queue }
}";
-        
-    public static void main(String...argv) throws Exception {
-        Preconditions.checkElementIndex(0, argv.length, "Must specify broker URL");
-        String url = argv[0];
-        
-        // Set Qpid client properties
-        System.setProperty(ClientProperties.AMQP_VERSION, "0-10");
-        System.setProperty(ClientProperties.DEST_SYNTAX, "ADDR");
-
-        // Connect to the broker
-        AMQConnectionFactory factory = new AMQConnectionFactory(url);
-        Connection connection = factory.createConnection();
-        connection.start();
-        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-        
-        try {
-            // Create a producer for the queue
-            Queue destination = session.createQueue(QUEUE);
-            MessageProducer messageProducer = session.createProducer(destination);
-
-            // Send 100 messages
-            for (int n = 0; n < 100; n++) {
-                String body = String.format("test message %03d", n+1);
-                TextMessage message = session.createTextMessage(body);
-                messageProducer.send(message);
-                System.out.printf("Sent message %s\n", body);
-            }
-        } catch (Exception e) {
-            System.err.printf("Error while sending - %s\n", e.getMessage());
-            System.err.printf("Cause: %s\n", Throwables.getStackTraceAsString(e));
-        } finally {
-            session.close();
-            connection.close();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f2792fa1/examples/simple-messaging-pubsub/src/main/java/brooklyn/demo/StandaloneQpidBrokerExample.java
----------------------------------------------------------------------
diff --git a/examples/simple-messaging-pubsub/src/main/java/brooklyn/demo/StandaloneQpidBrokerExample.java
b/examples/simple-messaging-pubsub/src/main/java/brooklyn/demo/StandaloneQpidBrokerExample.java
deleted file mode 100644
index 89f7874..0000000
--- a/examples/simple-messaging-pubsub/src/main/java/brooklyn/demo/StandaloneQpidBrokerExample.java
+++ /dev/null
@@ -1,73 +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 brooklyn.demo;
-
-import java.util.List;
-
-import brooklyn.entity.basic.AbstractApplication;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.basic.StartableApplication;
-import brooklyn.entity.messaging.amqp.AmqpServer;
-import brooklyn.entity.messaging.qpid.QpidBroker;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.launcher.BrooklynLauncher;
-import brooklyn.util.CommandLineUtil;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-
-/** Qpid Broker Application */
-public class StandaloneQpidBrokerExample extends AbstractApplication {
-
-    public static final String CUSTOM_CONFIG_PATH = "classpath://custom-config.xml";
-    public static final String PASSWD_PATH = "classpath://passwd";
-    public static final String QPID_BDBSTORE_JAR_PATH = "classpath://qpid-bdbstore-0.20.jar";
-    public static final String BDBSTORE_JAR_PATH = "classpath://je-5.0.34.jar";
-
-    public static final String DEFAULT_LOCATION = "localhost";
-    
-    @Override
-    public void initApp() {
-        // Configure the Qpid broker entity
-        QpidBroker broker = addChild(EntitySpec.create(QpidBroker.class)
-                .configure("amqpPort", 5672)
-                .configure("amqpVersion", AmqpServer.AMQP_0_10)
-                .configure("runtimeFiles", ImmutableMap.builder()
-                        .put(CUSTOM_CONFIG_PATH, QpidBroker.CONFIG_XML)
-                        .put(PASSWD_PATH, QpidBroker.PASSWD)
-                        .put(QPID_BDBSTORE_JAR_PATH, "lib/opt/qpid-bdbstore-0.20.jar")
-                        .put(BDBSTORE_JAR_PATH, "lib/opt/je-5.0.34.jar")
-                        .build())
-                .configure("queue", "testQueue"));
-    }
-
-    public static void main(String[] argv) {
-        List<String> args = Lists.newArrayList(argv);
-        String port =  CommandLineUtil.getCommandLineOption(args, "--port", "8081+");
-        String location = CommandLineUtil.getCommandLineOption(args, "--location", DEFAULT_LOCATION);
-
-        BrooklynLauncher launcher = BrooklynLauncher.newInstance()
-                .application(EntitySpec.create(StartableApplication.class, StandaloneQpidBrokerExample.class).displayName("Qpid
app"))
-                .webconsolePort(port)
-                .location(location)
-                .start();
-         
-        Entities.dumpInfo(launcher.getApplications());
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f2792fa1/examples/simple-messaging-pubsub/src/main/java/brooklyn/demo/Subscribe.java
----------------------------------------------------------------------
diff --git a/examples/simple-messaging-pubsub/src/main/java/brooklyn/demo/Subscribe.java b/examples/simple-messaging-pubsub/src/main/java/brooklyn/demo/Subscribe.java
deleted file mode 100644
index 7272887..0000000
--- a/examples/simple-messaging-pubsub/src/main/java/brooklyn/demo/Subscribe.java
+++ /dev/null
@@ -1,76 +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 brooklyn.demo;
-
-import javax.jms.Connection;
-import javax.jms.MessageConsumer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.qpid.client.AMQConnectionFactory;
-import org.apache.qpid.configuration.ClientProperties;
-
-import com.google.common.base.Preconditions;
-import com.google.common.base.Throwables;
-
-/** Receives messages from a queue on a Qpid broker at a given URL. */
-public class Subscribe {
-    public static final String QUEUE = "'amq.direct'/'testQueue'; { node: { type: queue }
}";
-    private static final long MESSAGE_TIMEOUT_MILLIS = 15000L;
-    private static final int MESSAGE_COUNT = 100;
-    
-    public static void main(String...argv) throws Exception {
-        Preconditions.checkElementIndex(0, argv.length, "Must specify broker URL");
-        String url = argv[0];
-
-        // Set Qpid client properties
-        System.setProperty(ClientProperties.AMQP_VERSION, "0-10");
-        System.setProperty(ClientProperties.DEST_SYNTAX, "ADDR");
-
-        // Connect to the broker
-        AMQConnectionFactory factory = new AMQConnectionFactory(url);
-        Connection connection = factory.createConnection();
-        connection.start();
-        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-        System.out.printf("Waiting up to %s milliseconds to receive %s messages\n", MESSAGE_TIMEOUT_MILLIS,
MESSAGE_COUNT);
-        try {
-            // Create a producer for the queue
-            Queue destination = session.createQueue(QUEUE);
-            MessageConsumer messageConsumer = session.createConsumer(destination);
-
-            // Try and receive 100 messages
-            for (int n = 0; n < MESSAGE_COUNT; n++) {
-                TextMessage msg = (TextMessage) messageConsumer.receive(MESSAGE_TIMEOUT_MILLIS);
-                if (msg == null) {
-                    System.out.printf("No message received in %s milliseconds, exiting",
MESSAGE_TIMEOUT_MILLIS);
-                    break;
-                }
-                System.out.printf("Got message %d: '%s'\n", n+1, msg.getText());
-            }
-        } catch (Exception e) {
-            System.err.printf("Error while receiving - %s\n", e.getMessage());
-            System.err.printf("Cause: %s\n", Throwables.getStackTraceAsString(e));
-        } finally {
-            session.close();
-            connection.close();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f2792fa1/examples/simple-messaging-pubsub/src/main/java/org/apache/brooklyn/demo/KafkaClusterExample.java
----------------------------------------------------------------------
diff --git a/examples/simple-messaging-pubsub/src/main/java/org/apache/brooklyn/demo/KafkaClusterExample.java
b/examples/simple-messaging-pubsub/src/main/java/org/apache/brooklyn/demo/KafkaClusterExample.java
new file mode 100644
index 0000000..f0d361e
--- /dev/null
+++ b/examples/simple-messaging-pubsub/src/main/java/org/apache/brooklyn/demo/KafkaClusterExample.java
@@ -0,0 +1,58 @@
+/*
+ * 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.brooklyn.demo;
+
+import java.util.List;
+
+import brooklyn.entity.basic.ApplicationBuilder;
+import brooklyn.entity.basic.Entities;
+import brooklyn.entity.messaging.kafka.KafkaCluster;
+import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.launcher.BrooklynLauncher;
+import brooklyn.util.CommandLineUtil;
+
+import com.google.common.collect.Lists;
+
+/** Kafka Cluster Application */
+public class KafkaClusterExample extends ApplicationBuilder {
+
+    public static final String DEFAULT_LOCATION = "localhost";
+
+    /** Configure the application. */
+    protected void doBuild() {
+        addChild(EntitySpec.create(KafkaCluster.class)
+                .configure("startTimeout", 300) // 5 minutes
+                .configure("initialSize", 2));
+        // TODO set application display name?
+    }
+
+    public static void main(String[] argv) {
+        List<String> args = Lists.newArrayList(argv);
+        String port =  CommandLineUtil.getCommandLineOption(args, "--port", "8081+");
+        String location = CommandLineUtil.getCommandLineOption(args, "--location", DEFAULT_LOCATION);
+
+        BrooklynLauncher launcher = BrooklynLauncher.newInstance()
+                .application(new KafkaClusterExample().appDisplayName("Kafka cluster application"))
+                .webconsolePort(port)
+                .location(location)
+                .start();
+
+        Entities.dumpInfo(launcher.getApplications());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f2792fa1/examples/simple-messaging-pubsub/src/main/java/org/apache/brooklyn/demo/Publish.java
----------------------------------------------------------------------
diff --git a/examples/simple-messaging-pubsub/src/main/java/org/apache/brooklyn/demo/Publish.java
b/examples/simple-messaging-pubsub/src/main/java/org/apache/brooklyn/demo/Publish.java
new file mode 100644
index 0000000..8a68061
--- /dev/null
+++ b/examples/simple-messaging-pubsub/src/main/java/org/apache/brooklyn/demo/Publish.java
@@ -0,0 +1,71 @@
+/*
+ * 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.brooklyn.demo;
+
+import javax.jms.Connection;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.apache.qpid.client.AMQConnectionFactory;
+import org.apache.qpid.configuration.ClientProperties;
+
+import com.google.common.base.Preconditions;
+import com.google.common.base.Throwables;
+
+/** Publishes messages to a queue on a Qpid broker at a given URL. */
+public class Publish {
+    public static final String QUEUE = "'amq.direct'/'testQueue'; { node: { type: queue }
}";
+        
+    public static void main(String...argv) throws Exception {
+        Preconditions.checkElementIndex(0, argv.length, "Must specify broker URL");
+        String url = argv[0];
+        
+        // Set Qpid client properties
+        System.setProperty(ClientProperties.AMQP_VERSION, "0-10");
+        System.setProperty(ClientProperties.DEST_SYNTAX, "ADDR");
+
+        // Connect to the broker
+        AMQConnectionFactory factory = new AMQConnectionFactory(url);
+        Connection connection = factory.createConnection();
+        connection.start();
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        
+        try {
+            // Create a producer for the queue
+            Queue destination = session.createQueue(QUEUE);
+            MessageProducer messageProducer = session.createProducer(destination);
+
+            // Send 100 messages
+            for (int n = 0; n < 100; n++) {
+                String body = String.format("test message %03d", n+1);
+                TextMessage message = session.createTextMessage(body);
+                messageProducer.send(message);
+                System.out.printf("Sent message %s\n", body);
+            }
+        } catch (Exception e) {
+            System.err.printf("Error while sending - %s\n", e.getMessage());
+            System.err.printf("Cause: %s\n", Throwables.getStackTraceAsString(e));
+        } finally {
+            session.close();
+            connection.close();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f2792fa1/examples/simple-messaging-pubsub/src/main/java/org/apache/brooklyn/demo/StandaloneQpidBrokerExample.java
----------------------------------------------------------------------
diff --git a/examples/simple-messaging-pubsub/src/main/java/org/apache/brooklyn/demo/StandaloneQpidBrokerExample.java
b/examples/simple-messaging-pubsub/src/main/java/org/apache/brooklyn/demo/StandaloneQpidBrokerExample.java
new file mode 100644
index 0000000..9df7005
--- /dev/null
+++ b/examples/simple-messaging-pubsub/src/main/java/org/apache/brooklyn/demo/StandaloneQpidBrokerExample.java
@@ -0,0 +1,73 @@
+/*
+ * 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.brooklyn.demo;
+
+import java.util.List;
+
+import brooklyn.entity.basic.AbstractApplication;
+import brooklyn.entity.basic.Entities;
+import brooklyn.entity.basic.StartableApplication;
+import brooklyn.entity.messaging.amqp.AmqpServer;
+import brooklyn.entity.messaging.qpid.QpidBroker;
+import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.launcher.BrooklynLauncher;
+import brooklyn.util.CommandLineUtil;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+
+/** Qpid Broker Application */
+public class StandaloneQpidBrokerExample extends AbstractApplication {
+
+    public static final String CUSTOM_CONFIG_PATH = "classpath://custom-config.xml";
+    public static final String PASSWD_PATH = "classpath://passwd";
+    public static final String QPID_BDBSTORE_JAR_PATH = "classpath://qpid-bdbstore-0.20.jar";
+    public static final String BDBSTORE_JAR_PATH = "classpath://je-5.0.34.jar";
+
+    public static final String DEFAULT_LOCATION = "localhost";
+    
+    @Override
+    public void initApp() {
+        // Configure the Qpid broker entity
+        QpidBroker broker = addChild(EntitySpec.create(QpidBroker.class)
+                .configure("amqpPort", 5672)
+                .configure("amqpVersion", AmqpServer.AMQP_0_10)
+                .configure("runtimeFiles", ImmutableMap.builder()
+                        .put(CUSTOM_CONFIG_PATH, QpidBroker.CONFIG_XML)
+                        .put(PASSWD_PATH, QpidBroker.PASSWD)
+                        .put(QPID_BDBSTORE_JAR_PATH, "lib/opt/qpid-bdbstore-0.20.jar")
+                        .put(BDBSTORE_JAR_PATH, "lib/opt/je-5.0.34.jar")
+                        .build())
+                .configure("queue", "testQueue"));
+    }
+
+    public static void main(String[] argv) {
+        List<String> args = Lists.newArrayList(argv);
+        String port =  CommandLineUtil.getCommandLineOption(args, "--port", "8081+");
+        String location = CommandLineUtil.getCommandLineOption(args, "--location", DEFAULT_LOCATION);
+
+        BrooklynLauncher launcher = BrooklynLauncher.newInstance()
+                .application(EntitySpec.create(StartableApplication.class, StandaloneQpidBrokerExample.class).displayName("Qpid
app"))
+                .webconsolePort(port)
+                .location(location)
+                .start();
+         
+        Entities.dumpInfo(launcher.getApplications());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f2792fa1/examples/simple-messaging-pubsub/src/main/java/org/apache/brooklyn/demo/Subscribe.java
----------------------------------------------------------------------
diff --git a/examples/simple-messaging-pubsub/src/main/java/org/apache/brooklyn/demo/Subscribe.java
b/examples/simple-messaging-pubsub/src/main/java/org/apache/brooklyn/demo/Subscribe.java
new file mode 100644
index 0000000..b7df104
--- /dev/null
+++ b/examples/simple-messaging-pubsub/src/main/java/org/apache/brooklyn/demo/Subscribe.java
@@ -0,0 +1,76 @@
+/*
+ * 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.brooklyn.demo;
+
+import javax.jms.Connection;
+import javax.jms.MessageConsumer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.apache.qpid.client.AMQConnectionFactory;
+import org.apache.qpid.configuration.ClientProperties;
+
+import com.google.common.base.Preconditions;
+import com.google.common.base.Throwables;
+
+/** Receives messages from a queue on a Qpid broker at a given URL. */
+public class Subscribe {
+    public static final String QUEUE = "'amq.direct'/'testQueue'; { node: { type: queue }
}";
+    private static final long MESSAGE_TIMEOUT_MILLIS = 15000L;
+    private static final int MESSAGE_COUNT = 100;
+    
+    public static void main(String...argv) throws Exception {
+        Preconditions.checkElementIndex(0, argv.length, "Must specify broker URL");
+        String url = argv[0];
+
+        // Set Qpid client properties
+        System.setProperty(ClientProperties.AMQP_VERSION, "0-10");
+        System.setProperty(ClientProperties.DEST_SYNTAX, "ADDR");
+
+        // Connect to the broker
+        AMQConnectionFactory factory = new AMQConnectionFactory(url);
+        Connection connection = factory.createConnection();
+        connection.start();
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+        System.out.printf("Waiting up to %s milliseconds to receive %s messages\n", MESSAGE_TIMEOUT_MILLIS,
MESSAGE_COUNT);
+        try {
+            // Create a producer for the queue
+            Queue destination = session.createQueue(QUEUE);
+            MessageConsumer messageConsumer = session.createConsumer(destination);
+
+            // Try and receive 100 messages
+            for (int n = 0; n < MESSAGE_COUNT; n++) {
+                TextMessage msg = (TextMessage) messageConsumer.receive(MESSAGE_TIMEOUT_MILLIS);
+                if (msg == null) {
+                    System.out.printf("No message received in %s milliseconds, exiting",
MESSAGE_TIMEOUT_MILLIS);
+                    break;
+                }
+                System.out.printf("Got message %d: '%s'\n", n+1, msg.getText());
+            }
+        } catch (Exception e) {
+            System.err.printf("Error while receiving - %s\n", e.getMessage());
+            System.err.printf("Cause: %s\n", Throwables.getStackTraceAsString(e));
+        } finally {
+            session.close();
+            connection.close();
+        }
+    }
+}


Mime
View raw message