camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject svn commit: r1244287 - in /camel/branches/camel-2.9.x/components/camel-jms/src: main/java/org/apache/camel/component/jms/JmsProducer.java test/java/org/apache/camel/component/jms/JmsRequestReplyCorrelationTest.java
Date Wed, 15 Feb 2012 00:22:22 GMT
Author: hadrian
Date: Wed Feb 15 00:22:20 2012
New Revision: 1244287

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

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

Modified: camel/branches/camel-2.9.x/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java?rev=1244287&r1=1244286&r2=1244287&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
(original)
+++ camel/branches/camel-2.9.x/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
Wed Feb 15 00:22:20 2012
@@ -147,7 +147,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.9.x/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyCorrelationTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyCorrelationTest.java?rev=1244287&r1=1244286&r2=1244287&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyCorrelationTest.java
(original)
+++ camel/branches/camel-2.9.x/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyCorrelationTest.java
Wed Feb 15 00:22:20 2012
@@ -93,6 +93,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



Mime
View raw message