You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ha...@apache.org on 2012/02/15 02:30:28 UTC

svn commit: r1244299 - in /camel/branches/camel-2.8.x/components/camel-jms/src: main/java/org/apache/camel/component/jms/JmsProducer.java test/java/org/apache/camel/component/jms/JmsRequestReplyCorrelationTest.java

Author: hadrian
Date: Wed Feb 15 01:30:28 2012
New Revision: 1244299

URL: http://svn.apache.org/viewvc?rev=1244299&view=rev
Log:
CAMEL-5006. Patch applied with thanks to Pat Fox

Modified:
    camel/branches/camel-2.8.x/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
    camel/branches/camel-2.8.x/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyCorrelationTest.java

Modified: camel/branches/camel-2.8.x/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java?rev=1244299&r1=1244298&r2=1244299&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java (original)
+++ camel/branches/camel-2.8.x/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java Wed Feb 15 01:30:28 2012
@@ -145,7 +145,7 @@ public class JmsProducer extends Default
         final ValueHolder<MessageSentCallback> sentCallback = new ValueHolder<MessageSentCallback>(messageSentCallback);
 
         final String originalCorrelationId = in.getHeader("JMSCorrelationID", String.class);
-        if (originalCorrelationId == null && !msgIdAsCorrId) {
+        if (ObjectHelper.isEmpty(originalCorrelationId) && !msgIdAsCorrId) {
             in.setHeader("JMSCorrelationID", getUuidGenerator().generateUuid());
         }
 

Modified: camel/branches/camel-2.8.x/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyCorrelationTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyCorrelationTest.java?rev=1244299&r1=1244298&r2=1244299&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyCorrelationTest.java (original)
+++ camel/branches/camel-2.8.x/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyCorrelationTest.java Wed Feb 15 01:30:28 2012
@@ -94,6 +94,37 @@ public class JmsRequestReplyCorrelationT
         assertFalse("CorrelationID should NOT start with ID, was: " + correlationId, correlationId.startsWith("ID:"));
     }
 
+    
+    /**
+     * When the setting useMessageIdAsCorrelationid is false and
+     * a correlation id is set to empty String ("") the message then we expect the reply
+     * to contain the correlation id dynamically generated on send.
+     */
+     
+     @Test
+     public void testRequestReplyCorrelationWithEmptyString() throws Exception {
+         MockEndpoint result = getMockEndpoint("mock:result");
+         result.expectedMessageCount(1);
+
+         Exchange out = template.send("jms:queue:hello", ExchangePattern.InOut, new Processor() {
+             public void process(Exchange exchange) throws Exception {
+                 Message in = exchange.getIn();
+                 in.setBody("Hello World");
+                 in.setHeader("JMSCorrelationID", "");
+             }
+         });
+
+         assertNotNull(out);
+         result.assertIsSatisfied();
+     
+         assertEquals(REPLY_BODY, out.getOut().getBody(String.class));
+         String correlationId = out.getOut().getHeader("JMSCorrelationID", String.class);
+         assertNotNull(correlationId);
+         // In ActiveMQ messageIds start with ID: (currently) so the ID should not be generated from AMQ
+         assertFalse("CorrelationID should NOT start with ID, was: " + correlationId, correlationId.startsWith("ID:"));
+     }
+    
+    
     /**
      * When the setting useMessageIdAsCorrelationid is true for the client and
      * false for the server and a correlation id is not set on the message then