This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch camel-2.22.x in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-2.22.x by this push: new 9ace951 CAMEL-13750: Omit JMSCorrelationID when sending with useMessageIDAsCorrelationID 9ace951 is described below commit 9ace951aee1577e431f1c6294c1330150ab9f1f5 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 ba79b0c..f3c02e9 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 @@ -375,7 +375,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 6e31aad..8ad4b34 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 @@ -218,6 +218,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(); @@ -251,7 +279,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);