This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch camel-3.18.x in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-3.18.x by this push: new 6abc81a19cc CAMEL-18626: Java DSL to allow property placeholders in setExchangePattern 6abc81a19cc is described below commit 6abc81a19ccffeb49a6c43eedadc1afdb99b6942 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Wed Oct 19 18:14:51 2022 +0200 CAMEL-18626: Java DSL to allow property placeholders in setExchangePattern --- .../java/org/apache/camel/model/ProcessorDefinition.java | 16 +++++++++++++++- .../apache/camel/processor/SetExchangePatternTest.java | 7 +++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinition.java index 7a1600f75c7..efbbf734c85 100644 --- a/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinition.java +++ b/core/camel-core-model/src/main/java/org/apache/camel/model/ProcessorDefinition.java @@ -580,7 +580,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> } /** - * <a href= "http://camel.apache.org/exchange-pattern.html">ExchangePattern:</a> set the {@link ExchangePattern} + * <a href="http://camel.apache.org/exchange-pattern.html">ExchangePattern:</a> set the {@link ExchangePattern} * into the {@link Exchange}. * <p/> * The pattern set on the {@link Exchange} will be changed from this point going foward. @@ -593,6 +593,20 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type> return asType(); } + /** + * <a href="http://camel.apache.org/exchange-pattern.html">ExchangePattern:</a> set the {@link ExchangePattern} + * into the {@link Exchange}. + * <p/> + * The pattern set on the {@link Exchange} will be changed from this point going foward. + * + * @param exchangePattern the exchange pattern + * @return the builder + */ + public Type setExchangePattern(String exchangePattern) { + addOutput(new SetExchangePatternDefinition(exchangePattern)); + return asType(); + } + /** * Sends the message to the given endpoint using an <a href="http://camel.apache.org/event-message.html">Event * Message</a> or <a href="http://camel.apache.org/exchange-pattern.html">InOnly exchange pattern</a> diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/SetExchangePatternTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/SetExchangePatternTest.java index 94947ee3a30..4071dcba964 100644 --- a/core/camel-core/src/test/java/org/apache/camel/processor/SetExchangePatternTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/processor/SetExchangePatternTest.java @@ -64,6 +64,11 @@ public class SetExchangePatternTest extends ContextTestSupport { assertMessageReceivedWithPattern("direct:testSetExchangePatternInOnly", ExchangePattern.InOnly); } + @Test + public void testSetAsString() throws Exception { + assertMessageReceivedWithPattern("direct:asString", ExchangePattern.InOut); + } + @Test public void testPreserveOldMEPInOut() throws Exception { // the mock should get an InOut MEP @@ -156,6 +161,8 @@ public class SetExchangePatternTest extends ContextTestSupport { // Set the exchange pattern to InOut, then send it on from("direct:testSetExchangePatternInOnly").setExchangePattern(ExchangePattern.InOnly).to("mock:result"); // END SNIPPET: example + + from("direct:asString").setExchangePattern("InOut").to("mock:result"); } }; }