activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r965542 - in /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp: LegacyFrameTranslator.java Stomp.java
Date Mon, 19 Jul 2010 16:10:23 GMT
Author: rajdavies
Date: Mon Jul 19 16:10:22 2010
New Revision: 965542

URL: http://svn.apache.org/viewvc?rev=965542&view=rev
Log:
Patch applied for  https://issues.apache.org/activemq/browse/AMQ-2833

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/LegacyFrameTranslator.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/Stomp.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/LegacyFrameTranslator.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/LegacyFrameTranslator.java?rev=965542&r1=965541&r2=965542&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/LegacyFrameTranslator.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/LegacyFrameTranslator.java
Mon Jul 19 16:10:22 2010
@@ -37,7 +37,28 @@ public class LegacyFrameTranslator imple
     public ActiveMQMessage convertFrame(ProtocolConverter converter, StompFrame command)
throws JMSException, ProtocolException {
         final Map headers = command.getHeaders();
         final ActiveMQMessage msg;
-        if (headers.containsKey(Stomp.Headers.CONTENT_LENGTH)) {
+        /*
+         * To reduce the complexity of this method perhaps a Chain of Responsibility
+         * would be a better implementation
+         */
+        if (headers.containsKey(Stomp.Headers.AMQ_MESSAGE_TYPE)) {
+            String intendedType = (String)headers.get(Stomp.Headers.AMQ_MESSAGE_TYPE);
+            if(intendedType.equalsIgnoreCase("text")){
+                ActiveMQTextMessage text = new ActiveMQTextMessage();
+                try {
+                    text.setText(new String(command.getContent(), "UTF-8"));
+                } catch (Throwable e) {
+                    throw new ProtocolException("Text could not bet set: " + e, false, e);
+                }
+                msg = text;
+            } else if(intendedType.equalsIgnoreCase("bytes")) {
+                ActiveMQBytesMessage byteMessage = new ActiveMQBytesMessage();
+                byteMessage.writeBytes(command.getContent());
+                msg = byteMessage;
+            } else {
+                throw new ProtocolException("Unsupported message type '"+intendedType+"'",false);
+            }
+        }else if (headers.containsKey(Stomp.Headers.CONTENT_LENGTH)) {
             headers.remove(Stomp.Headers.CONTENT_LENGTH);
             ActiveMQBytesMessage bm = new ActiveMQBytesMessage();
             bm.writeBytes(command.getContent());

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/Stomp.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/Stomp.java?rev=965542&r1=965541&r2=965542&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/Stomp.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/Stomp.java
Mon Jul 19 16:10:22 2010
@@ -50,6 +50,11 @@ public interface Stomp {
         String CONTENT_LENGTH = "content-length";
         String TRANSFORMATION = "transformation";
         String TRANSFORMATION_ERROR = "transformation-error";
+        /**
+         * This header is used to instruct ActiveMQ to construct the message
+         * based with a specific type.
+         */
+        String AMQ_MESSAGE_TYPE = "amq-msg-type";
 
         public interface Response {
             String RECEIPT_ID = "receipt-id";



Mime
View raw message