You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2026/02/13 15:34:52 UTC
(camel) branch main updated (bab70a39d4e8 -> 0a5f3db55ae4)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
from bab70a39d4e8 Remove deprecated use of PARENT_UNIT_OF_WORK that are no longer in use
new 14e6867eebd6 Update docs, and make camel-jbang auto import model package as inlined java dsl may use that
new 0a5f3db55ae4 camel-jbang: EIPs with AggregationStrategy should support stubbing as well
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../docs/modules/eips/pages/claimCheck-eip.adoc | 78 ++++++++++++++++++++++
.../modules/eips/pages/competing-consumers.adoc | 2 +-
.../eips/pages/composed-message-processor.adoc | 57 ++++++++++++++--
.../apache/camel/reifier/ClaimCheckReifier.java | 3 +
.../org/apache/camel/reifier/MulticastReifier.java | 3 +
.../org/apache/camel/reifier/ProcessorReifier.java | 3 +
.../apache/camel/reifier/RecipientListReifier.java | 3 +
.../org/apache/camel/reifier/SplitReifier.java | 3 +
.../org/apache/camel/support/PatternHelper.java | 5 ++
.../src/main/resources/templates/code-java.tmpl | 2 +
.../camel/main/download/StubBeanRepository.java | 5 ++
.../yaml/validator/stub/StubBeanRepository.java | 5 ++
12 files changed, 164 insertions(+), 5 deletions(-)
(camel) 02/02: camel-jbang: EIPs with AggregationStrategy should support stubbing as well
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 0a5f3db55ae48aed177d4f5a199b75f379728915
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Feb 13 16:34:30 2026 +0100
camel-jbang: EIPs with AggregationStrategy should support stubbing as well
---
.../modules/eips/pages/competing-consumers.adoc | 2 +-
.../eips/pages/composed-message-processor.adoc | 57 ++++++++++++++++++++--
.../apache/camel/reifier/ClaimCheckReifier.java | 3 ++
.../org/apache/camel/reifier/MulticastReifier.java | 3 ++
.../org/apache/camel/reifier/ProcessorReifier.java | 3 ++
.../apache/camel/reifier/RecipientListReifier.java | 3 ++
.../org/apache/camel/reifier/SplitReifier.java | 3 ++
.../org/apache/camel/support/PatternHelper.java | 5 ++
.../camel/main/download/StubBeanRepository.java | 5 ++
.../yaml/validator/stub/StubBeanRepository.java | 5 ++
10 files changed, 84 insertions(+), 5 deletions(-)
diff --git a/core/camel-core-engine/src/main/docs/modules/eips/pages/competing-consumers.adoc b/core/camel-core-engine/src/main/docs/modules/eips/pages/competing-consumers.adoc
index 0e122d97638c..14dcab6c178a 100644
--- a/core/camel-core-engine/src/main/docs/modules/eips/pages/competing-consumers.adoc
+++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/competing-consumers.adoc
@@ -177,4 +177,4 @@ into the backup folder. This is an important note that the on completion is done
This ensures the file is not moved before the file is processed successfully. Suppose the `calculateBean` bean
could not process one of the files. If it was the synchronous thread that should do the on completion strategy,
then the file would have been moved to early into the backup folder. By handing over this to the asynchronous
- thread, we do it after we have processed the message completely
+thread, we do it after we have processed the message completely
diff --git a/core/camel-core-engine/src/main/docs/modules/eips/pages/composed-message-processor.adoc b/core/camel-core-engine/src/main/docs/modules/eips/pages/composed-message-processor.adoc
index fe1d0d2cb7c7..1fd1a9874976 100644
--- a/core/camel-core-engine/src/main/docs/modules/eips/pages/composed-message-processor.adoc
+++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/composed-message-processor.adoc
@@ -22,17 +22,22 @@ aggregate and return a single combined response.
The route and the code comments below explain how you can use the xref:split-eip.adoc[Split] EIP to
split each message to sub-message which are processed individually and then combined back into
-a single response message via the custom `AggregationStrategy` (`MyOrderStrategy`), as the output from the Split EIP.
+a single response message via the custom `AggregationStrategy` (`myStrategy`), as the output from the Split EIP.
+[tabs]
+====
+Java::
++
[source,java]
----
// this routes starts from the direct:start endpoint
// the body is then split based on @ separator
// the splitter in Camel supports InOut as well, and for that we need
// to be able to aggregate what response we need to send back, so we provide our
-// own strategy with the class MyOrderStrategy.
+// own strategy with the class MyOrderStrategy which has been registered as a bean
+// with id myStrategy.
from("direct:start")
- .split(body().tokenize("@"), new MyOrderStrategy())
+ .split(simple("${split(@)}")).aggregationStrategy("myStrategy")
// each split message is then send to this bean where we can process it
.to("bean:MyOrderService?method=handleOrder")
// this is important to end the splitter route as we do not want to do more routing
@@ -40,10 +45,54 @@ from("direct:start")
.end()
// after we have split and handled each message, we want to send a single combined
// response back to the original caller, so we let this bean build it for us
- // this bean will receive the result of the aggregate strategy: MyOrderStrategy
+ // this bean will receive the result of the aggregate strategy
.to("bean:MyOrderService?method=buildCombinedResponse")
----
+XML::
++
+[source,xml]
+----
+<route>
+ <from uri="direct:start"/>
+ <split aggregationStrategy="myStrategy">
+ <simple>${split(@)}</simple>
+ <to uri="bean:MyOrderService?method=handleOrder"/>
+ </split>
+ <to uri="bean:MyOrderService?method=buildCombinedResponse"/>
+</route>
+----
+
+
+YAML::
++
+[source,yaml]
+----
+- route:
+ from:
+ uri: direct
+ parameters:
+ name: start
+ steps:
+ - split:
+ aggregationStrategy: myStrategy
+ expression:
+ simple:
+ expression: "${split(@)}"
+ steps:
+ - to:
+ uri: bean
+ parameters:
+ beanName: MyOrderService
+ method: handleOrder
+ - to:
+ uri: bean
+ parameters:
+ beanName: MyOrderService
+ method: buildCombinedResponse
+----
+====
+
== More details
See the xref:split-eip.adoc[Splitter] EIP.
diff --git a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/ClaimCheckReifier.java b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/ClaimCheckReifier.java
index b36c4fe63cb5..2504fa737666 100644
--- a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/ClaimCheckReifier.java
+++ b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/ClaimCheckReifier.java
@@ -116,6 +116,9 @@ public class ClaimCheckReifier extends ProcessorReifier<ClaimCheckDefinition> {
String ref = parseString(definition.getAggregationStrategy());
if (strategy == null && ref != null) {
Object aggStrategy = lookupByName(ref);
+ if (aggStrategy == null) {
+ aggStrategy = lookupByNameAndType(ref, AggregationStrategy.class);
+ }
if (aggStrategy instanceof AggregationStrategy aggregationStrategy) {
strategy = aggregationStrategy;
} else if (aggStrategy instanceof BiFunction biFunction) {
diff --git a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/MulticastReifier.java b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/MulticastReifier.java
index 2b84b0246e85..b1ed396ff781 100644
--- a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/MulticastReifier.java
+++ b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/MulticastReifier.java
@@ -92,6 +92,9 @@ public class MulticastReifier extends ProcessorReifier<MulticastDefinition> {
String ref = parseString(definition.getAggregationStrategy());
if (strategy == null && ref != null) {
Object aggStrategy = lookupByName(ref);
+ if (aggStrategy == null) {
+ aggStrategy = lookupByNameAndType(ref, AggregationStrategy.class);
+ }
if (aggStrategy instanceof AggregationStrategy aggregationStrategy) {
strategy = aggregationStrategy;
} else if (aggStrategy instanceof BiFunction biFunction) {
diff --git a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/ProcessorReifier.java b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/ProcessorReifier.java
index bc4fa9ade67b..86ebf04c5220 100644
--- a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/ProcessorReifier.java
+++ b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/ProcessorReifier.java
@@ -912,6 +912,9 @@ public abstract class ProcessorReifier<T extends ProcessorDefinition<?>> extends
AggregationStrategy strategy = definition.getAggregationStrategyBean();
if (strategy == null && definition.getAggregationStrategyRef() != null) {
Object aggStrategy = lookupByName(definition.getAggregationStrategyRef());
+ if (aggStrategy == null) {
+ aggStrategy = lookupByNameAndType(definition.getAggregationStrategyRef(), AggregationStrategy.class);
+ }
if (aggStrategy instanceof AggregationStrategy aggregationStrategy) {
strategy = aggregationStrategy;
} else if (aggStrategy instanceof BiFunction biFunction) {
diff --git a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/RecipientListReifier.java b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/RecipientListReifier.java
index 71dc229cdb62..992e731f35d4 100644
--- a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/RecipientListReifier.java
+++ b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/RecipientListReifier.java
@@ -118,6 +118,9 @@ public class RecipientListReifier extends ProcessorReifier<RecipientListDefiniti
String ref = parseString(definition.getAggregationStrategy());
if (strategy == null && ref != null) {
Object aggStrategy = lookupByName(ref);
+ if (aggStrategy == null) {
+ aggStrategy = lookupByNameAndType(ref, AggregationStrategy.class);
+ }
if (aggStrategy instanceof AggregationStrategy aggregationStrategy) {
strategy = aggregationStrategy;
} else if (aggStrategy instanceof BiFunction biFunction) {
diff --git a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/SplitReifier.java b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/SplitReifier.java
index 1068698603a1..77d0fb583dfb 100644
--- a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/SplitReifier.java
+++ b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/SplitReifier.java
@@ -85,6 +85,9 @@ public class SplitReifier extends ExpressionReifier<SplitDefinition> {
AggregationStrategy strategy = definition.getAggregationStrategyBean();
if (strategy == null && definition.getAggregationStrategy() != null) {
Object aggStrategy = lookupByName(definition.getAggregationStrategy());
+ if (aggStrategy == null) {
+ aggStrategy = lookupByNameAndType(definition.getAggregationStrategy(), AggregationStrategy.class);
+ }
if (aggStrategy instanceof AggregationStrategy aggregationStrategy) {
strategy = aggregationStrategy;
} else if (aggStrategy instanceof BiFunction biFunction) {
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/PatternHelper.java b/core/camel-support/src/main/java/org/apache/camel/support/PatternHelper.java
index b0c562a7b5ed..dd784ae5ae47 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/PatternHelper.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/PatternHelper.java
@@ -58,6 +58,11 @@ public final class PatternHelper {
return true;
}
+ if ("*".equals(pattern)) {
+ // matches everything
+ return true;
+ }
+
if (matchWildcard(name, pattern)) {
return true;
}
diff --git a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/StubBeanRepository.java b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/StubBeanRepository.java
index 4457d3abb61f..20466d4a4d98 100644
--- a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/StubBeanRepository.java
+++ b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/download/StubBeanRepository.java
@@ -21,7 +21,9 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
+import org.apache.camel.AggregationStrategy;
import org.apache.camel.processor.DefaultClaimCheckRepository;
+import org.apache.camel.processor.aggregate.GroupedBodyAggregationStrategy;
import org.apache.camel.processor.aggregate.MemoryAggregationRepository;
import org.apache.camel.spi.AggregationRepository;
import org.apache.camel.spi.BeanRepository;
@@ -92,6 +94,9 @@ public class StubBeanRepository implements BeanRepository {
if (StateRepository.class.isAssignableFrom(type)) {
return (T) new MemoryStateRepository();
}
+ if (AggregationStrategy.class.isAssignableFrom(type)) {
+ return (T) new GroupedBodyAggregationStrategy();
+ }
return null;
}
}
diff --git a/dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/main/java/org/apache/camel/dsl/yaml/validator/stub/StubBeanRepository.java b/dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/main/java/org/apache/camel/dsl/yaml/validator/stub/StubBeanRepository.java
index 9557db7d05f3..1ba9aa3a93fd 100644
--- a/dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/main/java/org/apache/camel/dsl/yaml/validator/stub/StubBeanRepository.java
+++ b/dsl/camel-yaml-dsl/camel-yaml-dsl-validator/src/main/java/org/apache/camel/dsl/yaml/validator/stub/StubBeanRepository.java
@@ -21,7 +21,9 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
+import org.apache.camel.AggregationStrategy;
import org.apache.camel.processor.DefaultClaimCheckRepository;
+import org.apache.camel.processor.aggregate.GroupedBodyAggregationStrategy;
import org.apache.camel.processor.aggregate.MemoryAggregationRepository;
import org.apache.camel.spi.AggregationRepository;
import org.apache.camel.spi.BeanRepository;
@@ -78,6 +80,9 @@ public class StubBeanRepository implements BeanRepository {
if (StateRepository.class.isAssignableFrom(type)) {
return (T) new MemoryStateRepository();
}
+ if (AggregationStrategy.class.isAssignableFrom(type)) {
+ return (T) new GroupedBodyAggregationStrategy();
+ }
return null;
}
}
(camel) 01/02: Update docs, and make camel-jbang auto import model package as inlined java dsl may use that
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 14e6867eebd63dec729bb9f7441a4686670bdedb
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Feb 13 16:00:04 2026 +0100
Update docs, and make camel-jbang auto import model package as inlined java dsl may use that
---
.../docs/modules/eips/pages/claimCheck-eip.adoc | 78 ++++++++++++++++++++++
.../src/main/resources/templates/code-java.tmpl | 2 +
2 files changed, 80 insertions(+)
diff --git a/core/camel-core-engine/src/main/docs/modules/eips/pages/claimCheck-eip.adoc b/core/camel-core-engine/src/main/docs/modules/eips/pages/claimCheck-eip.adoc
index f736fab5190b..eb7615a81bef 100644
--- a/core/camel-core-engine/src/main/docs/modules/eips/pages/claimCheck-eip.adoc
+++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/claimCheck-eip.adoc
@@ -141,6 +141,10 @@ Note you cannot have both include (`+`) and exclude (`-`) `header:pattern` at th
The claim check keys are static, but you can use the `simple` language syntax to define dynamic keys.
For example, to use a header from the message named `myKey`:
+[tabs]
+====
+Java::
++
[source,java]
----
from("direct:start")
@@ -156,6 +160,80 @@ from("direct:start")
.to("mock:e");
----
+XML::
++
+[source,xml]
+----
+<route>
+ <from uri="direct:start"/>
+ <to uri="mock:a"/>
+ <claimCheck operation="Set" key="${header.myKey}"/>
+ <transform>
+ <constant>Bye World</constant>
+ </transform>
+ <to uri="mock:b"/>
+ <claimCheck operation="Get" key="${header.myKey}"/>
+ <to uri="mock:c"/>
+ <transform>
+ <constant>Hi World</constant>
+ </transform>
+ <to uri="mock:d"/>
+ <claimCheck operation="Get" key="${header.myKey}"/>
+ <to uri="mock:e"/>
+</route>
+----
+
+YAML::
++
+[source,yaml]
+----
+- route:
+ from:
+ uri: direct
+ parameters:
+ name: start
+ steps:
+ - to:
+ uri: mock
+ parameters:
+ name: a
+ - claimCheck:
+ operation: Set
+ key: "${header.myKey}"
+ - transform:
+ expression:
+ constant:
+ expression: Bye World
+ - to:
+ uri: mock
+ parameters:
+ name: b
+ - claimCheck:
+ operation: Get
+ key: "${header.myKey}"
+ - to:
+ uri: mock
+ parameters:
+ name: c
+ - transform:
+ expression:
+ constant:
+ expression: Hi World
+ - to:
+ uri: mock
+ parameters:
+ name: d
+ - claimCheck:
+ operation: Get
+ key: "${header.myKey}"
+ - to:
+ uri: mock
+ parameters:
+ name: e
+----
+
+====
+
== Example
The following example shows the `Push` and `Pop` operations in action:
diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/code-java.tmpl b/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/code-java.tmpl
index dc02d4175506..bc7951a62a2d 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/code-java.tmpl
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/resources/templates/code-java.tmpl
@@ -2,6 +2,8 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
+import org.apache.camel.model.*;
+import org.apache.camel.spi.*;
public class {{ .Name }} extends RouteBuilder {