This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-4.10.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.10.x by this push:
new 699169a3bfe CAMEL-22001: camel-core - Kamelet/seda and EIPs should
propagate exchange variables (#17827)
699169a3bfe is described below
commit 699169a3bfefe05869ab8418915a274ba8a5c883
Author: Claus Ibsen <[email protected]>
AuthorDate: Tue Apr 22 14:29:28 2025 +0200
CAMEL-22001: camel-core - Kamelet/seda and EIPs should propagate exchange
variables (#17827)
---
...ameletEIPPropagateVariableAsResultTestTest.java | 44 ++++++++
.../KameletPropagateVariableAsResultTestTest.java | 65 ++++++++++++
.../EnrichPropagateVariableAsResultTestTest.java | 62 +++++++++++
.../LoopCopyPropagateVariableAsResultTestTest.java | 52 +++++++++
...ollEnrichPropagateVariableAsResultTestTest.java | 66 ++++++++++++
...utingSlipPropagateVariableAsResultTestTest.java | 60 +++++++++++
.../SedaPropagateVariableAsResultTestTest.java | 62 +++++++++++
...ationStrategyPropagateVariableAsResultTest.java | 118 +++++++++++++++++++++
.../org/apache/camel/support/ExchangeHelper.java | 3 +
9 files changed, 532 insertions(+)
diff --git
a/components/camel-kamelet/src/test/java/org/apache/camel/component/kamelet/KameletEIPPropagateVariableAsResultTestTest.java
b/components/camel-kamelet/src/test/java/org/apache/camel/component/kamelet/KameletEIPPropagateVariableAsResultTestTest.java
new file mode 100644
index 00000000000..89ac9cf3318
--- /dev/null
+++
b/components/camel-kamelet/src/test/java/org/apache/camel/component/kamelet/KameletEIPPropagateVariableAsResultTestTest.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kamelet;
+
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+
+public class KameletEIPPropagateVariableAsResultTestTest extends
KameletPropagateVariableAsResultTestTest {
+
+ @Override
+ protected RoutesBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ routeTemplate("slip")
+ .templateParameter("queue")
+ .templateParameter("letter")
+ .from("kamelet:source")
+ .transform(simple("${body}{{letter}}"))
+ .setVariable("{{queue}}", simple("${body}"));
+
+ from("direct:start")
+ .kamelet("slip?queue=foo1&letter=B")
+ .kamelet("slip?queue=foo2&letter=C")
+ .kamelet("slip?queue=foo3&letter=D")
+ .to("mock:result");
+ }
+ };
+ }
+}
diff --git
a/components/camel-kamelet/src/test/java/org/apache/camel/component/kamelet/KameletPropagateVariableAsResultTestTest.java
b/components/camel-kamelet/src/test/java/org/apache/camel/component/kamelet/KameletPropagateVariableAsResultTestTest.java
new file mode 100644
index 00000000000..1b1612cbc07
--- /dev/null
+++
b/components/camel-kamelet/src/test/java/org/apache/camel/component/kamelet/KameletPropagateVariableAsResultTestTest.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kamelet;
+
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+public class KameletPropagateVariableAsResultTestTest extends CamelTestSupport
{
+
+ @Test
+ public void testVariable() throws Exception {
+ getMockEndpoint("mock:result").expectedBodiesReceived("ABCD");
+ getMockEndpoint("mock:result").expectedVariableReceived("foo1", "AB");
+ getMockEndpoint("mock:result").expectedVariableReceived("foo2", "ABC");
+ getMockEndpoint("mock:result").expectedVariableReceived("foo3",
"ABCD");
+
+ template.requestBody("direct:start", "A");
+
+ MockEndpoint.assertIsSatisfied(context);
+ }
+
+ // **********************************************
+ //
+ // test set-up
+ //
+ // **********************************************
+
+ @Override
+ protected RoutesBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ routeTemplate("slip")
+ .templateParameter("queue")
+ .templateParameter("letter")
+ .from("kamelet:source")
+ .transform(simple("${body}{{letter}}"))
+ .setVariable("{{queue}}", simple("${body}"));
+
+ from("direct:start")
+ .to("kamelet:slip?queue=foo1&letter=B")
+ .to("kamelet:slip?queue=foo2&letter=C")
+ .to("kamelet:slip?queue=foo3&letter=D")
+ .to("mock:result");
+ }
+ };
+ }
+}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/processor/EnrichPropagateVariableAsResultTestTest.java
b/core/camel-core/src/test/java/org/apache/camel/processor/EnrichPropagateVariableAsResultTestTest.java
new file mode 100644
index 00000000000..84efbe5daf8
--- /dev/null
+++
b/core/camel-core/src/test/java/org/apache/camel/processor/EnrichPropagateVariableAsResultTestTest.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.jupiter.api.Test;
+
+public class EnrichPropagateVariableAsResultTestTest extends
ContextTestSupport {
+
+ @Test
+ public void testEnrich() throws Exception {
+ getMockEndpoint("mock:result").expectedBodiesReceived("ABCD");
+ getMockEndpoint("mock:result").expectedVariableReceived("foo1", "AB");
+ getMockEndpoint("mock:result").expectedVariableReceived("foo2", "ABC");
+ getMockEndpoint("mock:result").expectedVariableReceived("foo3",
"ABCD");
+
+ template.sendBody("direct:start", "A");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:start")
+ .enrich("direct:slip1")
+ .enrich("direct:slip2")
+ .enrich("direct:slip3")
+ .to("mock:result");
+
+ from("direct:slip1")
+ .transform(body().append("B"))
+ .setVariable("foo1", simple("${body}"));
+
+ from("direct:slip2")
+ .transform(body().append("C"))
+ .setVariable("foo2", simple("${body}"));
+
+ from("direct:slip3")
+ .transform(body().append("D"))
+ .setVariable("foo3", simple("${body}"));
+ }
+ };
+ }
+}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/processor/LoopCopyPropagateVariableAsResultTestTest.java
b/core/camel-core/src/test/java/org/apache/camel/processor/LoopCopyPropagateVariableAsResultTestTest.java
new file mode 100644
index 00000000000..24a7995eb00
--- /dev/null
+++
b/core/camel-core/src/test/java/org/apache/camel/processor/LoopCopyPropagateVariableAsResultTestTest.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.jupiter.api.Test;
+
+public class LoopCopyPropagateVariableAsResultTestTest extends
ContextTestSupport {
+
+ @Test
+ public void testLoopCopy() throws Exception {
+ getMockEndpoint("mock:loop").expectedBodiesReceived("AB", "AB", "AB");
+ getMockEndpoint("mock:loop").expectedVariableReceived("foo", "AB");
+ getMockEndpoint("mock:result").expectedBodiesReceived("AB");
+ getMockEndpoint("mock:result").expectedVariableReceived("foo", "AB");
+
+ template.sendBody("direct:start", "A");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:start")
+ .loop(3).copy()
+ .transform(body().append("B"))
+ .setVariable("foo", simple("${body}"))
+ .to("mock:loop")
+ .end()
+ .to("mock:result");
+ }
+ };
+ }
+}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/processor/PollEnrichPropagateVariableAsResultTestTest.java
b/core/camel-core/src/test/java/org/apache/camel/processor/PollEnrichPropagateVariableAsResultTestTest.java
new file mode 100644
index 00000000000..0eca1262cd6
--- /dev/null
+++
b/core/camel-core/src/test/java/org/apache/camel/processor/PollEnrichPropagateVariableAsResultTestTest.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.jupiter.api.Test;
+
+public class PollEnrichPropagateVariableAsResultTestTest extends
ContextTestSupport {
+
+ @Test
+ public void testPollEnrich() throws Exception {
+ getMockEndpoint("mock:result").expectedBodiesReceived("ABCD");
+ getMockEndpoint("mock:result").expectedVariableReceived("foo1", "AB");
+ getMockEndpoint("mock:result").expectedVariableReceived("foo2", "ABC");
+ getMockEndpoint("mock:result").expectedVariableReceived("foo3",
"ABCD");
+
+ template.sendBody("direct:slip1", "AB");
+ template.sendBody("direct:slip2", "ABC");
+ template.sendBody("direct:slip3", "ABCD");
+
+ template.sendBody("direct:start", "A");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:start")
+ .pollEnrich("seda:slip1", 1000)
+ .pollEnrich("seda:slip2", 1000)
+ .pollEnrich("seda:slip3", 1000)
+ .to("mock:result");
+
+ from("direct:slip1")
+ .setVariable("foo1", simple("${body}"))
+ .to("seda:slip1");
+
+ from("direct:slip2")
+ .setVariable("foo2", simple("${body}"))
+ .to("seda:slip2");
+
+ from("direct:slip3")
+ .setVariable("foo3", simple("${body}"))
+ .to("seda:slip3");
+ }
+ };
+ }
+}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/processor/RoutingSlipPropagateVariableAsResultTestTest.java
b/core/camel-core/src/test/java/org/apache/camel/processor/RoutingSlipPropagateVariableAsResultTestTest.java
new file mode 100644
index 00000000000..56fc26ad8e2
--- /dev/null
+++
b/core/camel-core/src/test/java/org/apache/camel/processor/RoutingSlipPropagateVariableAsResultTestTest.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.jupiter.api.Test;
+
+public class RoutingSlipPropagateVariableAsResultTestTest extends
ContextTestSupport {
+
+ @Test
+ public void testRoutingSlip() throws Exception {
+ getMockEndpoint("mock:result").expectedBodiesReceived("ABCD");
+ getMockEndpoint("mock:result").expectedVariableReceived("foo1", "AB");
+ getMockEndpoint("mock:result").expectedVariableReceived("foo2", "ABC");
+ getMockEndpoint("mock:result").expectedVariableReceived("foo3",
"ABCD");
+
+ template.sendBodyAndHeader("direct:start", "A", "slip",
"direct:slip1,direct:slip2,direct:slip3");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:start")
+ .routingSlip(header("slip"))
+ .to("mock:result");
+
+ from("direct:slip1")
+ .transform(body().append("B"))
+ .setVariable("foo1", simple("${body}"));
+
+ from("direct:slip2")
+ .transform(body().append("C"))
+ .setVariable("foo2", simple("${body}"));
+
+ from("direct:slip3")
+ .transform(body().append("D"))
+ .setVariable("foo3", simple("${body}"));
+ }
+ };
+ }
+}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/processor/SedaPropagateVariableAsResultTestTest.java
b/core/camel-core/src/test/java/org/apache/camel/processor/SedaPropagateVariableAsResultTestTest.java
new file mode 100644
index 00000000000..fff5fd8f7ab
--- /dev/null
+++
b/core/camel-core/src/test/java/org/apache/camel/processor/SedaPropagateVariableAsResultTestTest.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.jupiter.api.Test;
+
+public class SedaPropagateVariableAsResultTestTest extends ContextTestSupport {
+
+ @Test
+ public void testSeda() throws Exception {
+ getMockEndpoint("mock:result").expectedBodiesReceived("ABCD");
+ getMockEndpoint("mock:result").expectedVariableReceived("foo1", "AB");
+ getMockEndpoint("mock:result").expectedVariableReceived("foo2", "ABC");
+ getMockEndpoint("mock:result").expectedVariableReceived("foo3",
"ABCD");
+
+ template.requestBody("direct:start", "A");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:start")
+ .to("seda:slip1")
+ .to("seda:slip2")
+ .to("seda:slip3")
+ .to("mock:result");
+
+ from("seda:slip1")
+ .transform(body().append("B"))
+ .setVariable("foo1", simple("${body}"));
+
+ from("seda:slip2")
+ .transform(body().append("C"))
+ .setVariable("foo2", simple("${body}"));
+
+ from("seda:slip3")
+ .transform(body().append("D"))
+ .setVariable("foo3", simple("${body}"));
+ }
+ };
+ }
+}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/processor/SplitterAggregationStrategyPropagateVariableAsResultTest.java
b/core/camel-core/src/test/java/org/apache/camel/processor/SplitterAggregationStrategyPropagateVariableAsResultTest.java
new file mode 100644
index 00000000000..3eb8e4b79d8
--- /dev/null
+++
b/core/camel-core/src/test/java/org/apache/camel/processor/SplitterAggregationStrategyPropagateVariableAsResultTest.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.AggregationStrategy;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class SplitterAggregationStrategyPropagateVariableAsResultTest extends
ContextTestSupport {
+
+ @Test
+ public void testSplitVariable() throws Exception {
+ getMockEndpoint("mock:split").expectedMessageCount(3);
+ getMockEndpoint("mock:result").expectedMessageCount(1);
+
+ template.sendBody("direct:start", "A,B,C");
+
+ assertMockEndpointsSatisfied();
+
+ MockEndpoint result = getMockEndpoint("mock:result");
+ Exchange e = result.getExchanges().get(0);
+ Assertions.assertNotNull(e);
+
+ Assertions.assertTrue(e.hasProperties());
+ List<?> l = e.getProperty("REP_PROP", List.class);
+ Assertions.assertNotNull(l);
+ Assertions.assertEquals(3, l.size());
+ Assertions.assertEquals("A", l.get(0));
+ Assertions.assertEquals("B", l.get(1));
+ Assertions.assertEquals("C", l.get(2));
+
+ Assertions.assertTrue(e.getMessage().hasHeaders());
+ l = e.getMessage().getHeader("REP_HEAD", List.class);
+ Assertions.assertNotNull(l);
+ Assertions.assertEquals(3, l.size());
+ Assertions.assertEquals("A", l.get(0));
+ Assertions.assertEquals("B", l.get(1));
+ Assertions.assertEquals("C", l.get(2));
+
+ Assertions.assertTrue(e.hasVariables());
+ l = e.getVariable("REP_VAL", List.class);
+ Assertions.assertNotNull(l);
+ Assertions.assertEquals(3, l.size());
+ Assertions.assertEquals("A", l.get(0));
+ Assertions.assertEquals("B", l.get(1));
+ Assertions.assertEquals("C", l.get(2));
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:start")
+ .split(body().tokenize(","), new AggregationStrategy()
{
+ @Override
+ public Exchange aggregate(Exchange oldExchange,
Exchange newExchange) {
+ var newBody =
newExchange.getMessage().getBody(String.class);
+
+ if (oldExchange == null) {
+ List<String> bodies = new ArrayList<>();
+ List<String> properties = new
ArrayList<>();
+ List<String> headers = new ArrayList<>();
+ List<String> variables = new ArrayList<>();
+
+ bodies.add(newBody);
+ properties.add(newBody);
+ headers.add(newBody);
+ variables.add(newBody);
+
+ newExchange.getMessage().setBody(bodies);
+
newExchange.getMessage().setHeader("REP_HEAD", headers);
+ newExchange.setProperty("REP_PROP",
properties);
+ newExchange.setVariable("REP_VAL",
variables);
+
+ return newExchange;
+ }
+
+ var bodies =
oldExchange.getMessage().getBody(List.class);
+ var properties =
oldExchange.getProperty("REP_PROP", List.class);
+ var headers =
oldExchange.getMessage().getHeader("REP_HEAD", List.class);
+ var variable =
oldExchange.getVariable("REP_VAL", List.class);
+
+ bodies.add(newBody);
+ properties.add(newBody);
+ headers.add(newBody);
+ variable.add(newBody);
+
+ return oldExchange;
+ }
+ })
+ .to("mock:split")
+ .end()
+ .to("mock:result");
+ }
+ };
+ }
+}
diff --git
a/core/camel-support/src/main/java/org/apache/camel/support/ExchangeHelper.java
b/core/camel-support/src/main/java/org/apache/camel/support/ExchangeHelper.java
index 1d09ab4315c..c8fcc9e3f96 100644
---
a/core/camel-support/src/main/java/org/apache/camel/support/ExchangeHelper.java
+++
b/core/camel-support/src/main/java/org/apache/camel/support/ExchangeHelper.java
@@ -375,6 +375,9 @@ public final class ExchangeHelper {
if (source.hasProperties()) {
result.getProperties().putAll(source.getProperties());
}
+ if (source.hasVariables()) {
+ result.getVariables().putAll(source.getVariables());
+ }
final ExchangeExtension sourceExtension =
source.getExchangeExtension();
sourceExtension.copyInternalProperties(result);