activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r367741 - in /incubator/activemq/trunk/activemq-core/src: main/java/org/apache/activemq/command/ActiveMQMessage.java main/java/org/apache/activemq/command/MessageId.java test/java/org/apache/activemq/command/ActiveMQMessageTest.java
Date Tue, 10 Jan 2006 19:14:08 GMT
Author: jstrachan
Date: Tue Jan 10 11:14:01 2006
New Revision: 367741

URL: http://svn.apache.org/viewcvs?rev=367741&view=rev
Log:
fix to allow a foreign JMS message ID to be set on an ActiveMQMessage

Modified:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMessage.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/MessageId.java
    incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/command/ActiveMQMessageTest.java

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMessage.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMessage.java?rev=367741&r1=367740&r2=367741&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMessage.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMessage.java
Tue Jan 10 11:14:01 2006
@@ -114,8 +114,13 @@
             try {
                 MessageId id = new MessageId(value);
                 this.setMessageId(id);
-            } catch (Throwable e) {
-                throw JMSExceptionSupport.create("Invalid message id '" + value + "', reason:
" + e.getMessage(), e);
+            }
+            catch (NumberFormatException e) {
+                // we must be some foreign JMS provider or strange user-supplied String
+                // so lets set the IDs to be 1
+                MessageId id = new MessageId();
+                id.setTextView(value);
+                this.setMessageId(messageId);
             }
         } else {
             this.setMessageId(null);

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/MessageId.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/MessageId.java?rev=367741&r1=367740&r2=367741&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/MessageId.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/MessageId.java
Tue Jan 10 11:14:01 2006
@@ -42,7 +42,7 @@
     }
 
     public MessageId(String messageKey) {
-        setMessageKey(messageKey);
+        setValue(messageKey);
     }
     
     public MessageId(String producerId, long producerSequenceId) {
@@ -54,17 +54,28 @@
         this.producerSequenceId = producerSequenceId;        
     }
     
-    public void setMessageKey(String messageKey) {
+    /**
+     * Sets the value as a String
+     */
+    public void setValue(String messageKey) {
         key = messageKey;
-        // Parse off the sequenceId
-        int p = messageKey.lastIndexOf(":");
-        if( p >= 0 ) {
-            producerSequenceId = Long.parseLong(messageKey.substring(p+1));
-            messageKey = messageKey.substring(0,p);
-        }
-        producerId = new ProducerId(messageKey);
+            // Parse off the sequenceId
+            int p = messageKey.lastIndexOf(":");
+            if( p >= 0 ) {
+                producerSequenceId = Long.parseLong(messageKey.substring(p+1));
+                messageKey = messageKey.substring(0,p);
+            }
+            producerId = new ProducerId(messageKey);
     }
     
+    /**
+     * Sets the transient text view of the message which will be ignored
+     * if the message is marshaled on a transport; so is only for in-JVM changes
+     * to accommodate foreign JMS message IDs
+     */
+    public void setTextView(String key) {
+        this.key = key;
+    }
 
     public byte getDataStructureType() {
         return DATA_STRUCTURE_TYPE;

Modified: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/command/ActiveMQMessageTest.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/command/ActiveMQMessageTest.java?rev=367741&r1=367740&r2=367741&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/command/ActiveMQMessageTest.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/command/ActiveMQMessageTest.java
Tue Jan 10 11:14:01 2006
@@ -129,6 +129,11 @@
         assertTrue(test);
     }
 
+    public void testSetToForeignJMSID() throws Exception {
+        ActiveMQMessage msg = new ActiveMQMessage();
+        msg.setJMSMessageID("ID:EMS-SERVER.8B443C380083:429");
+        
+    }
     /*
      * Class to test for boolean equals(Object)
      */



Mime
View raw message