This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch camel-2.24.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-2.24.x by this push:
     new 19b535f  CAMEL-13750: Omit JMSCorrelationID when sending with 
useMessageIDAsCorrelationID
19b535f is described below

commit 19b535fe5295a695961de15d9cf26de9619d7f34
Author: Alvin Kwekel <al...@liberition.com>
AuthorDate: Thu Jul 18 15:55:43 2019 +0200

    CAMEL-13750: Omit JMSCorrelationID when sending with 
useMessageIDAsCorrelationID
---
 .../org/apache/camel/component/jms/JmsBinding.java |  2 +-
 .../jms/JmsRequestReplyCorrelationTest.java        | 30 +++++++++++++++++++++-
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git 
a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
 
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
index 450e683..2d080f4 100644
--- 
a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
+++ 
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
@@ -376,7 +376,7 @@ public class JmsBinding {
     public void appendJmsProperty(Message jmsMessage, Exchange exchange, 
org.apache.camel.Message in,
                                   String headerName, Object headerValue) 
throws JMSException {
         if (isStandardJMSHeader(headerName)) {
-            if (headerName.equals("JMSCorrelationID")) {
+            if (headerName.equals("JMSCorrelationID") && 
!endpoint.isUseMessageIDAsCorrelationID()) {
                 
jmsMessage.setJMSCorrelationID(ExchangeHelper.convertToType(exchange, 
String.class, headerValue));
             } else if (headerName.equals("JMSReplyTo") && headerValue != null) 
{
                 if (headerValue instanceof String) {
diff --git 
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyCorrelationTest.java
 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyCorrelationTest.java
index 79574a8..63dd8ef 100644
--- 
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyCorrelationTest.java
+++ 
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyCorrelationTest.java
@@ -219,6 +219,34 @@ public class JmsRequestReplyCorrelationTest extends 
CamelTestSupport {
         assertEquals("a", out.getOut().getHeader("JMSCorrelationID"));
     }
 
+    /**
+     * When the setting useMessageIdAsCorrelationid is true for the client and
+     * false for the server and a correlation id is set on the message then
+     * we expect the client to omit the correlation id on the JMS message to 
force
+     * the server to use the message id. But the correlation id should still be
+     * available on the client exchange message afterwards.
+     */
+    @Test
+    public void testRequestReplyCorrelationByMessageIdWithGivenCorrelationId() 
throws Exception {
+        MockEndpoint result = getMockEndpoint("mock:result");
+        result.expectedMessageCount(1);
+
+        Exchange out = template.send("jms2:queue:hello", 
ExchangePattern.InOut, new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                Message in = exchange.getIn();
+                in.setBody("Hello World");
+                in.setHeader("JMSCorrelationID", "a");
+            }
+        });
+
+        result.assertIsSatisfied();
+
+        assertNotNull(out);
+
+        assertEquals(REPLY_BODY, out.getOut().getBody(String.class));
+        assertEquals("a", out.getOut().getHeader("JMSCorrelationID"));
+    }
+
     @Override
     protected CamelContext createCamelContext() throws Exception {
         CamelContext camelContext = super.createCamelContext();
@@ -252,7 +280,7 @@ public class JmsRequestReplyCorrelationTest extends 
CamelTestSupport {
                         
assertNotNull(exchange.getIn().getHeader("JMSReplyTo"));
                     }
                 }).to("mock:result");
-                
+
                 
from("jms:queue:helloDelay").delay().constant(2000).process(new Processor() {
                     public void process(Exchange exchange) throws Exception {
                         exchange.getIn().setBody(REPLY_BODY);

Reply via email to