activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andytay...@apache.org
Subject [1/2] activemq-6 git commit: Improve jms/Stomp example - add receiving stomp response from server.
Date Mon, 09 Mar 2015 09:26:06 GMT
Repository: activemq-6
Updated Branches:
  refs/heads/master 10bb4568c -> 1a8951a56


Improve jms/Stomp example
  - add receiving stomp response from server.


Project: http://git-wip-us.apache.org/repos/asf/activemq-6/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-6/commit/fdff838d
Tree: http://git-wip-us.apache.org/repos/asf/activemq-6/tree/fdff838d
Diff: http://git-wip-us.apache.org/repos/asf/activemq-6/diff/fdff838d

Branch: refs/heads/master
Commit: fdff838d78702be9cd00ac67b93b2812d717be7c
Parents: 3c99562
Author: Howard Gao <hgao@redhat.com>
Authored: Mon Mar 9 10:48:26 2015 +0800
Committer: Howard Gao <hgao@redhat.com>
Committed: Mon Mar 9 10:49:52 2015 +0800

----------------------------------------------------------------------
 .../apache/activemq/jms/example/StompExample.java   | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-6/blob/fdff838d/examples/jms/stomp/src/main/java/org/apache/activemq/jms/example/StompExample.java
----------------------------------------------------------------------
diff --git a/examples/jms/stomp/src/main/java/org/apache/activemq/jms/example/StompExample.java
b/examples/jms/stomp/src/main/java/org/apache/activemq/jms/example/StompExample.java
index bd3f84a..048be82 100644
--- a/examples/jms/stomp/src/main/java/org/apache/activemq/jms/example/StompExample.java
+++ b/examples/jms/stomp/src/main/java/org/apache/activemq/jms/example/StompExample.java
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.jms.example;
 
+import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.Socket;
 import java.nio.charset.StandardCharsets;
@@ -28,6 +29,7 @@ import javax.jms.Session;
 import javax.jms.TextMessage;
 import javax.naming.InitialContext;
 
+
 import org.apache.activemq.common.example.ActiveMQExample;
 
 /**
@@ -65,6 +67,8 @@ public class StompExample extends ActiveMQExample
             END_OF_FRAME;
          sendFrame(socket, connectFrame);
 
+         readFrame(socket);
+
          // Step 3. Send a SEND frame (a Stomp message) to the
          // jms.queue.exampleQueue address with a text body
          String text = "Hello, world from Stomp!";
@@ -133,4 +137,16 @@ public class StompExample extends ActiveMQExample
       outputStream.flush();
    }
 
+   private static String readFrame(Socket socket) throws Exception
+   {
+      byte[] bytes = new byte[2048];
+      InputStream inputStream = socket.getInputStream();
+      int nbytes = inputStream.read(bytes);
+      byte[] data = new byte[nbytes];
+      System.arraycopy(bytes, 0, data, 0, data.length);
+      String resp = new String(data, "UTF-8");
+      System.out.println("Got response from server: " + resp);
+      return resp;
+   }
+
 }


Mime
View raw message