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 00:36:04 UTC
svn commit: r1244274 - in /camel/trunk/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: Tue Feb 14 23:36:03 2012
New Revision: 1244274
URL: http://svn.apache.org/viewvc?rev=1244274&view=rev
Log:
CAMEL-5006. Patch applied with thanks to Pat Fox
Modified:
camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyCorrelationTest.java
Modified: camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java?rev=1244274&r1=1244273&r2=1244274&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java (original)
+++ camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsProducer.java Tue Feb 14 23:36:03 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/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyCorrelationTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyCorrelationTest.java?rev=1244274&r1=1244273&r2=1244274&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyCorrelationTest.java (original)
+++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyCorrelationTest.java Tue Feb 14 23:36:03 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