You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/02/01 18:46:49 UTC

[19/50] brooklyn-library git commit: Update following PR comments

Update following PR comments


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

Branch: refs/heads/0.6.0
Commit: c59df12db8d1082cbcb733c5ad6e11d68d697353
Parents: dc43620
Author: Martin Harris <gi...@nakomis.com>
Authored: Mon Nov 4 18:12:16 2013 +0000
Committer: Martin Harris <gi...@nakomis.com>
Committed: Mon Nov 4 18:12:16 2013 +0000

----------------------------------------------------------------------
 .../src/main/java/brooklyn/demo/Subscribe.java          | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/c59df12d/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
index 6e852ad..0a51cf2 100644
--- a/examples/simple-messaging-pubsub/src/main/java/brooklyn/demo/Subscribe.java
+++ b/examples/simple-messaging-pubsub/src/main/java/brooklyn/demo/Subscribe.java
@@ -39,12 +39,14 @@ public class Subscribe {
             MessageConsumer messageConsumer = session.createConsumer(destination);
 
             // Try and receive 100 messages
-            int n = MESSAGE_COUNT;
-            do {
+            for (int n = 0; n < 100; n++) {
                 TextMessage msg = (TextMessage) messageConsumer.receive(MESSAGE_TIMEOUT_MILLIS);
-                if (msg == null) break;
-                System.out.printf("Got message: '%s'\n", msg.getText());
-            } while (--n > 0);
+                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));