camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [camel] 20/45: CAMEL-12882: Camel Jms headers missing if producer endpoint has transferExchange=true
Date Thu, 18 Oct 2018 16:02:44 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 4c05e0f6bee3483f5fd7614aa83fd84fc446218f
Author: Claus Ibsen <claus.ibsen@gmail.com>
AuthorDate: Tue Oct 16 08:09:59 2018 +0200

    CAMEL-12882: Camel Jms headers missing if producer endpoint has transferExchange=true
---
 .../src/main/java/org/apache/camel/component/jms/JmsBinding.java       | 3 +++
 .../java/org/apache/camel/component/jms/JmsTransferExchangeTest.java   | 3 +++
 2 files changed, 6 insertions(+)

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 bc9ed09..1b76d15 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
@@ -146,6 +146,9 @@ public class JmsBinding {
                 if (payload instanceof DefaultExchangeHolder) {
                     DefaultExchangeHolder holder = (DefaultExchangeHolder) payload;
                     DefaultExchangeHolder.unmarshal(exchange, holder);
+                    // enrich with JMS headers also as otherwise they will get lost when
use the transferExchange option.
+                    Map<String, Object> jmsHeaders = extractHeadersFromJms(message,
exchange);
+                    exchange.getIn().getHeaders().putAll(jmsHeaders);
                     return exchange.getIn().getBody();
                 } else {
                     return objectMessage.getObject();
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsTransferExchangeTest.java
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsTransferExchangeTest.java
index f492959..c649b70 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsTransferExchangeTest.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsTransferExchangeTest.java
@@ -38,6 +38,7 @@ public class JmsTransferExchangeTest extends CamelTestSupport {
     public void testBodyOnly() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedBodiesReceived("Hello World");
+        mock.expectedHeaderReceived("JMSDestination", "queue://foo");
 
         template.sendBody("direct:start", "Hello World");
 
@@ -49,6 +50,7 @@ public class JmsTransferExchangeTest extends CamelTestSupport {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedBodiesReceived("Hello World");
         mock.expectedHeaderReceived("foo", "cheese");
+        mock.expectedHeaderReceived("JMSDestination", "queue://foo");
 
         template.sendBodyAndHeader("direct:start", "Hello World", "foo", "cheese");
 
@@ -61,6 +63,7 @@ public class JmsTransferExchangeTest extends CamelTestSupport {
         mock.expectedBodiesReceived("Hello World");
         mock.expectedHeaderReceived("foo", "cheese");
         mock.expectedPropertyReceived("bar", 123);
+        mock.expectedHeaderReceived("JMSDestination", "queue://foo");
 
         template.send("direct:start", new Processor() {
             public void process(Exchange exchange) throws Exception {


Mime
View raw message