activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r725019 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/ActiveMQSession.java test/java/org/apache/activemq/JMSMessageTest.java
Date Wed, 10 Dec 2008 07:14:21 GMT
Author: djencks
Date: Tue Dec  9 23:14:21 2008
New Revision: 725019

URL: http://svn.apache.org/viewvc?rev=725019&view=rev
Log:
AMQ-2029 set JMS* headers on non-amq messages, with a test

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JMSMessageTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java?rev=725019&r1=725018&r2=725019&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/ActiveMQSession.java Tue
Dec  9 23:14:21 2008
@@ -1603,6 +1603,21 @@
             TransactionId txid = transactionContext.getTransactionId();
             long sequenceNumber = producer.getMessageSequence();
 
+            //Set the "JMS" header fields on the orriginal message, see 1.1 spec section
3.4.11
+            message.setJMSDestination(destination);
+            message.setJMSDeliveryMode(deliveryMode);
+            long expiration = 0L;
+            if (!producer.getDisableMessageTimestamp()) {
+                long timeStamp = System.currentTimeMillis();
+                message.setJMSTimestamp(timeStamp);
+                if (timeToLive > 0) {
+                    expiration = timeToLive + timeStamp;
+                }
+            }
+            message.setJMSExpiration(expiration);
+            message.setJMSPriority(priority);
+            message.setJMSRedelivered(false);
+
             // transform to our own message format here
             ActiveMQMessage msg = ActiveMQMessageTransformation.transformMessage(message,
connection);
 
@@ -1616,19 +1631,6 @@
             //clear the brokerPath in case we are re-sending this message
             msg.setBrokerPath(null);
 
-            msg.setJMSDestination(destination);
-            msg.setJMSDeliveryMode(deliveryMode);
-            long expiration = 0L;
-            if (!producer.getDisableMessageTimestamp()) {
-                long timeStamp = System.currentTimeMillis();
-                msg.setJMSTimestamp(timeStamp);
-                if (timeToLive > 0) {
-                    expiration = timeToLive + timeStamp;
-                }
-            }
-            msg.setJMSExpiration(expiration);
-            msg.setJMSPriority(priority);
-            msg.setJMSRedelivered(false);
 
             msg.setTransactionId(txid);
             if (connection.isCopyMessageOnSend()) {

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JMSMessageTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JMSMessageTest.java?rev=725019&r1=725018&r2=725019&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JMSMessageTest.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JMSMessageTest.java Tue
Dec  9 23:14:21 2008
@@ -465,7 +465,23 @@
             ForeignMessage message = new ForeignMessage();
             message.text = "Hello";
             message.setStringProperty("test", "value");
-            producer.send(message);
+            long timeToLive = 10000L;
+            long start = System.currentTimeMillis();
+            producer.send(message, Session.AUTO_ACKNOWLEDGE, 7, timeToLive);
+            long end = System.currentTimeMillis();
+
+
+            //validate jms spec 1.1 section 3.4.11 table 3.1
+            // JMSDestination, JMSDeliveryMode,  JMSExpiration, JMSPriority, JMSMessageID,
and JMSTimestamp
+            //must be set by sending a message.
+            assertEquals(destination, message.getJMSDestination());
+            assertEquals(Session.AUTO_ACKNOWLEDGE, message.getJMSDeliveryMode());
+            assertTrue(start  + timeToLive <= message.getJMSExpiration());
+            assertTrue(end + timeToLive >= message.getJMSExpiration());
+            assertEquals(7, message.getJMSPriority());
+            assertNotNull(message.getJMSMessageID());
+            assertTrue(start <= message.getJMSTimestamp());
+            assertTrue(end >= message.getJMSTimestamp());
         }
 
         // Validate message is OK.



Mime
View raw message