camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1137696 - in /camel/trunk/components/camel-jms/src: main/java/org/apache/camel/component/jms/ test/java/org/apache/camel/component/jms/
Date Mon, 20 Jun 2011 16:44:00 GMT
Author: davsclaus
Date: Mon Jun 20 16:44:00 2011
New Revision: 1137696

URL: http://svn.apache.org/viewvc?rev=1137696&view=rev
Log:
CAMEL-4123: Created javax.jms.Message should have default delivery mode preset. CAMEL-4124:
Fixed issue with using preserveMessageQos not preserving JMSDeliveryMode under certain curcomstanses.

Modified:
    camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
    camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConfiguration.java
    camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessageHelper.java
    camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteDeliveryModePreserveQoSTest.java

Modified: camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java?rev=1137696&r1=1137695&r2=1137696&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
(original)
+++ camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
Mon Jun 20 16:44:00 2011
@@ -400,7 +400,10 @@ public class JmsBinding {
 
     protected Message createJmsMessage(Exception cause, Session session) throws JMSException
{
         LOG.trace("Using JmsMessageType: {}", Object);
-        return session.createObjectMessage(cause);
+        Message answer = session.createObjectMessage(cause);
+        // ensure default delivery mode is used by default
+        answer.setJMSDeliveryMode(Message.DEFAULT_DELIVERY_MODE);
+        return answer;
     }
 
     protected Message createJmsMessage(Exchange exchange, Object body, Map<String, Object>
headers, Session session, CamelContext context) throws JMSException {
@@ -410,7 +413,10 @@ public class JmsBinding {
         if (endpoint != null && endpoint.isTransferExchange()) {
             LOG.trace("Option transferExchange=true so we use JmsMessageType: Object");
             Serializable holder = DefaultExchangeHolder.marshal(exchange);
-            return session.createObjectMessage(holder);
+            Message answer = session.createObjectMessage(holder);
+            // ensure default delivery mode is used by default
+            answer.setJMSDeliveryMode(Message.DEFAULT_DELIVERY_MODE);
+            return answer;
         }
 
         // use a custom message converter
@@ -434,7 +440,10 @@ public class JmsBinding {
         // create the JmsMessage based on the type
         if (type != null) {
             LOG.trace("Using JmsMessageType: {}", type);
-            return createJmsMessageForType(exchange, body, headers, session, context, type);
+            Message answer = createJmsMessageForType(exchange, body, headers, session, context,
type);
+            // ensure default delivery mode is used by default
+            answer.setJMSDeliveryMode(Message.DEFAULT_DELIVERY_MODE);
+            return answer;
         }
 
         // warn if the body could not be mapped
@@ -447,7 +456,10 @@ public class JmsBinding {
         }
 
         // return a default message
-        return session.createMessage();
+        Message answer = session.createMessage();
+        // ensure default delivery mode is used by default
+        answer.setJMSDeliveryMode(Message.DEFAULT_DELIVERY_MODE);
+        return answer;
     }
 
     /**

Modified: camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConfiguration.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConfiguration.java?rev=1137696&r1=1137695&r2=1137696&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConfiguration.java
(original)
+++ camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsConfiguration.java
Mon Jun 20 16:44:00 2011
@@ -243,7 +243,8 @@ public class JmsConfiguration implements
                     // remove the temporary property
                     JmsMessageHelper.removeJmsProperty(message, JmsConstants.JMS_DELIVERY_MODE);
                 } else {
-                    deliveryMode = this.getDeliveryMode();
+                    // use the existing delivery mode from the message
+                    deliveryMode = message.getJMSDeliveryMode();
                 }
 
                 // need to log just before so the message is 100% correct when logged

Modified: camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessageHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessageHelper.java?rev=1137696&r1=1137695&r2=1137696&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessageHelper.java
(original)
+++ camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsMessageHelper.java
Mon Jun 20 16:44:00 2011
@@ -227,7 +227,7 @@ public final class JmsMessageHelper {
      * @throws javax.jms.JMSException is thrown if error setting the delivery mode
      */
     public static void setJMSDeliveryMode(Exchange exchange, Message message, Object deliveryMode)
throws JMSException {
-        int mode = Message.DEFAULT_DELIVERY_MODE;
+        Integer mode = null;
 
         if (deliveryMode instanceof String) {
             String s = (String) deliveryMode;
@@ -252,8 +252,10 @@ public final class JmsMessageHelper {
             }
         }
 
-        message.setJMSDeliveryMode(mode);
-        message.setIntProperty(JmsConstants.JMS_DELIVERY_MODE, mode);
+        if (mode != null) {
+            message.setJMSDeliveryMode(mode);
+            message.setIntProperty(JmsConstants.JMS_DELIVERY_MODE, mode);
+        }
     }
 
 }

Modified: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteDeliveryModePreserveQoSTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteDeliveryModePreserveQoSTest.java?rev=1137696&r1=1137695&r2=1137696&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteDeliveryModePreserveQoSTest.java
(original)
+++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRouteDeliveryModePreserveQoSTest.java
Mon Jun 20 16:44:00 2011
@@ -118,10 +118,10 @@ public class JmsRouteDeliveryModePreserv
             @Override
             public void configure() throws Exception {
                 from("activemq:queue:foo")
-                    .to("log:foo")
                     .to("activemq:queue:bar?preserveMessageQos=true");
 
-                from("activemq:queue:bar").to("mock:bar");
+                from("activemq:queue:bar")
+                    .to("mock:bar");
             }
         };
     }



Mime
View raw message