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
The following commit(s) were added to refs/heads/main by this push:
new 94837340703d CAMEL-16861: Update docs
94837340703d is described below
commit 94837340703df746493d4b16359758b8722d7436
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Feb 18 12:12:22 2026 +0100
CAMEL-16861: Update docs
---
.../modules/eips/pages/transactional-client.adoc | 67 ++++++++++++++++++----
.../docs/modules/eips/pages/transform-eip.adoc | 18 +++---
.../modules/eips/pages/transformDataType-eip.adoc | 17 +++---
.../docs/modules/eips/pages/unmarshal-eip.adoc | 59 +++++++++++--------
.../apache/camel/model/ProcessorDefinition.java | 2 +-
.../camel/model/TransformDataTypeDefinition.java | 2 +-
.../org/apache/camel/main/stub/StubEipReifier.java | 14 +++++
7 files changed, 126 insertions(+), 53 deletions(-)
diff --git
a/core/camel-core-engine/src/main/docs/modules/eips/pages/transactional-client.adoc
b/core/camel-core-engine/src/main/docs/modules/eips/pages/transactional-client.adoc
index c5a5d59c50e3..9de39f9addc8 100644
---
a/core/camel-core-engine/src/main/docs/modules/eips/pages/transactional-client.adoc
+++
b/core/camel-core-engine/src/main/docs/modules/eips/pages/transactional-client.adoc
@@ -19,11 +19,12 @@ a third-party JTA transaction manager can be embedded and
used.
In Camel transactions are supported by JMS messaging components:
-- xref:ROOT:jms-component.adoc[JMS]
+- xref:ROOT:activemq-component.adoc[ActiveMQ 5.x] and
xref:ROOT:activemq6-component.adoc[ActiveMQ 6.x]
+- xref:ROOT:jms-component.adoc[JMS] (any JMS broker such as ActiveMQ Artemis)
- xref:ROOT:sjms-component.adoc[Simple JMS]
- xref:ROOT:sjms2-component.adoc[Simple JMS 2.x]
-And all the SQL database components, such as:
+And the SQL database components, such as:
- xref:ROOT:jdbc-component.adoc[JDBC]
- xref:ROOT:jpa-component.adoc[JPA]
@@ -75,8 +76,8 @@ transactions can be simpler to orchestrate by the transaction
manager. This is k
When using local transactions with Spring Transactions, then you can use the
dedicated transaction manager
for the resource type such as:
-- org.springframework.jdbc.datasource.DataSourceTransactionManager
-- org.springframework.jms.connection.JmsTransactionManager
+- `org.springframework.jdbc.datasource.DataSourceTransactionManager`
+- `org.springframework.jms.connection.JmsTransactionManager`
TIP: Consult the Spring documentation for more local transaction managers.
@@ -159,6 +160,19 @@ XML::
</route>
----
+YAML::
++
+[source,yaml]
+----
+- route:
+ from:
+ uri: jms:cheese
+ steps:
+ - transacted: {}
+ - to:
+ uri: bean:foo
+----
+
====
When you specify `<transacted/>` in a route, Camel uses transactions for that
particular
@@ -191,8 +205,13 @@ outcomes; for example, transaction 1 can roll back, while
transaction 2 commits,
and vice versa.
In Camel, you need to configure the propagations using
`SpringTransactionPolicy`
-as shown in the following XML snippets:
+as shown in the following Spring XML snippets:
+[tabs]
+====
+
+Spring XML::
++
[source,xml]
----
<bean id="txRequired"
class="org.apache.camel.spring.spi.SpringTransactionPolicy">
@@ -209,9 +228,15 @@ as shown in the following XML snippets:
<property name="propagationBehaviorName"
value="PROPAGATION_REQUIRES_MANDATORY"/>
</bean>
----
+====
Then we have routes where each of the routes uses their different policy:
+[tabs]
+====
+
+Spring XML::
++
[source,xml]
----
<camelContext xmlns="http://camel.apache.org/schema/spring">
@@ -236,6 +261,7 @@ Then we have routes where each of the routes uses their
different policy:
</route>
</camelContext>
----
+====
Notice how the ref attribute on `<transacted>` refers to the corresponding
bean id of the transaction policy.
@@ -250,7 +276,7 @@ control.
These two endpoints insert data into a database.
The sample is in its full as a
-https://github.com/apache/camel/tree/main/components/camel-spring-xml/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceMinimalConfigurationTest.java[unit
test].
+https://github.com/apache/camel/blob/main/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceWithOnExceptionMinimalConfigurationTest.java[unit
test].
First, we set up the usual spring stuff in its configuration file.
Here we have defined a DataSource to the HSQLDB and most
@@ -263,6 +289,11 @@ configure a transaction policy bean, so we do not have any
All the beans needed to be configured are
*standard* Spring beans only, there is no Camel specific configuration at all.
+[tabs]
+====
+
+Spring XML::
++
[source,xml]
----
<!-- this example uses JDBC so we define a data source -->
@@ -281,6 +312,7 @@ All the beans needed to be configured are
<property name="dataSource" ref="dataSource"/>
</bean>
----
+====
Then we are ready to define our Camel routes. We have two routes: 1 for
success conditions, and 1 for a forced rollback condition.
@@ -288,6 +320,11 @@ success conditions, and 1 for a forced rollback condition.
This is, after all, based on a unit test. Notice that we mark each route
as transacted using the `<transacted/>` XML tag.
+[tabs]
+====
+
+Spring XML::
++
[source,xml]
----
<camelContext xmlns="http://camel.apache.org/schema/spring">
@@ -326,11 +363,10 @@ as transacted using the `<transacted/>` XML tag.
</camelContext>
----
+====
That is all that is needed to configure a Camel route as being transacted.
-Remember to use `<transacted/>`.
-The rest is standard Spring
-XML to set up the transaction manager.
+Remember to use `<transacted/>`. The rest is standard Spring XML to set up the
transaction manager.
== Transaction example with JMS
@@ -344,6 +380,11 @@ First, we configure the standard Spring XML to declare a
JMS connection
factory, a JMS transaction manager and our ActiveMQ component that we
use in our routing.
+[tabs]
+====
+
+Spring XML::
++
[source,xml]
----
<!-- setup JMS connection factory -->
@@ -372,10 +413,16 @@ use in our routing.
<property name="transactionManager" ref="jmsTransactionManager"/>
</bean>
----
+====
And then we configure our routes. Notice that all we have to do is mark the
route as transacted using the `<transacted/>` XML tag.
+[tabs]
+====
+
+Spring XML::
++
[source,xml]
----
<camelContext xmlns="http://camel.apache.org/schema/spring">
@@ -391,4 +438,4 @@ route as transacted using the `<transacted/>` XML tag.
</route>
</camelContext>
----
-
+====
diff --git
a/core/camel-core-engine/src/main/docs/modules/eips/pages/transform-eip.adoc
b/core/camel-core-engine/src/main/docs/modules/eips/pages/transform-eip.adoc
index 866566bd6bc4..2f28b97427bd 100644
--- a/core/camel-core-engine/src/main/docs/modules/eips/pages/transform-eip.adoc
+++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/transform-eip.adoc
@@ -77,14 +77,16 @@ YAML::
+
[source,yaml]
----
-- from:
- uri: direct:cheese
- steps:
- - transform:
- expression:
- simple: Hello ${body}
- - to:
- uri: log:hello
+- route:
+ from:
+ uri: direct:cheese
+ steps:
+ - transform:
+ expression:
+ simple:
+ expression: "Hello ${body}"
+ - to:
+ uri: log:hello
----
====
diff --git
a/core/camel-core-engine/src/main/docs/modules/eips/pages/transformDataType-eip.adoc
b/core/camel-core-engine/src/main/docs/modules/eips/pages/transformDataType-eip.adoc
index 591553f62a86..58b34f4e79c7 100644
---
a/core/camel-core-engine/src/main/docs/modules/eips/pages/transformDataType-eip.adoc
+++
b/core/camel-core-engine/src/main/docs/modules/eips/pages/transformDataType-eip.adoc
@@ -71,17 +71,18 @@ YAML::
+
[source,yaml]
----
-- from:
- uri: direct:cheese
- steps:
- - transformDataType:
- toType: myDataType
- - to:
- uri: log:hello
+- route:
+ from:
+ uri: direct:cheese
+ steps:
+ - transformDataType:
+ toType: myDataType
+ - to:
+ uri: log:hello
----
====
The example above defines the xref:transformDataType-eip.adoc[Transform
DataType] EIP that uses a target data type `myDataType`.
The given data type may reference a xref:manual::transformer.adoc[Transformer]
that is able to handle the data type transformation.
-Users may also specify `fromType` in order to reference a very specific
transformation from a given data type to a given data type.
+NOTE: Users may also specify `fromType` in order to reference a very specific
transformation from a given data type to a given data type.
diff --git
a/core/camel-core-engine/src/main/docs/modules/eips/pages/unmarshal-eip.adoc
b/core/camel-core-engine/src/main/docs/modules/eips/pages/unmarshal-eip.adoc
index baaf626f5c7c..08569a7e6cba 100644
--- a/core/camel-core-engine/src/main/docs/modules/eips/pages/unmarshal-eip.adoc
+++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/unmarshal-eip.adoc
@@ -34,6 +34,7 @@ And finally, the message is routed to a
xref:ROOT:jms-component.adoc[JMS] queue.
[tabs]
====
+
Java::
+
[source,java]
@@ -62,56 +63,64 @@ YAML::
+
[source,yaml]
----
-- from:
- uri: file:inbox/xml
- steps:
- - unmarshal:
- jaxb: {}
- - to:
- uri: bean:validateOrder
- - marshal:
- jaxb: {}
- - to:
- uri: jms:queue:order
+- route:
+ from:
+ uri: file:inbox/xml
+ steps:
+ - unmarshal:
+ jaxb: {}
+ - to:
+ uri: bean:validateOrder
+ - marshal:
+ jaxb: {}
+ - to:
+ uri: jms:queue:order
----
====
== Allow Null Body
-Sometimes,
-there are situations where `null` can be a normal value for the body of a
message but `null` by default is not an accepted value to unmarshal.
-To work around that,
-it is possible to allow `null` as value to a body to unmarshall
+Sometimes, there are situations where `null` can be a normal value for the
body of a message but `null` by default is not an accepted value to unmarshal.
+To work around that, it is possible to allow `null` as value to a body to
unmarshall
using the option `allowNullBody` as shown in the next code snippets:
[tabs]
====
+
Java::
+
[source,java]
----
-// Beginning of the route
+from("file:inbox/xml")
.unmarshal().allowNullBody().jaxb()
-// End of the route
+ .to("bean:validateOrder");
----
XML::
+
[source,xml]
----
-<!-- Beginning of the route -->
- <unmarshal allowNullBody="true"><jaxb/></unmarshal>
-<!-- End of the route -->
+<route>
+ <from uri="file:inbox/xml"/>
+ <unmarshal allowNullBody="true">
+ <jaxb/>
+ </unmarshal>
+ <to uri="bean:validateOrder"/>
+</route>
----
YAML::
+
[source,yaml]
----
-# Beginning of the route
-unmarshal:
- allowNullBody: true
- jaxb: {}
-# End of the route
+- route:
+ from:
+ uri: file:inbox/xml
+ steps:
+ - unmarshal:
+ allowNullBody: "true"
+ jaxb: {}
+ - to:
+ uri: bean:validateOrder
----
====
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 c5a03df5c820..4294361765fd 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
@@ -2898,7 +2898,7 @@ public abstract class ProcessorDefinition<Type extends
ProcessorDefinition<Type>
* @return the builder
*/
public Type transformDataType(DataType toType) {
- TransformDataTypeDefinition answer = new
TransformDataTypeDefinition(DataType.ANY, toType);
+ TransformDataTypeDefinition answer = new
TransformDataTypeDefinition(null, toType);
addOutput(answer);
return asType();
}
diff --git
a/core/camel-core-model/src/main/java/org/apache/camel/model/TransformDataTypeDefinition.java
b/core/camel-core-model/src/main/java/org/apache/camel/model/TransformDataTypeDefinition.java
index 9c8ed1513279..fc0ebf873235 100644
---
a/core/camel-core-model/src/main/java/org/apache/camel/model/TransformDataTypeDefinition.java
+++
b/core/camel-core-model/src/main/java/org/apache/camel/model/TransformDataTypeDefinition.java
@@ -47,7 +47,7 @@ public class TransformDataTypeDefinition extends
NoOutputDefinition<TransformDat
}
public TransformDataTypeDefinition(DataType fromType, DataType toType) {
- this.fromType = fromType.getFullName();
+ this.fromType = fromType != null ? fromType.getFullName() : null;
this.toType = toType.getFullName();
}
diff --git
a/dsl/camel-kamelet-main-support/src/main/java/org/apache/camel/main/stub/StubEipReifier.java
b/dsl/camel-kamelet-main-support/src/main/java/org/apache/camel/main/stub/StubEipReifier.java
index c6622c94b7c9..e27e4f8c2943 100644
---
a/dsl/camel-kamelet-main-support/src/main/java/org/apache/camel/main/stub/StubEipReifier.java
+++
b/dsl/camel-kamelet-main-support/src/main/java/org/apache/camel/main/stub/StubEipReifier.java
@@ -28,6 +28,7 @@ import org.apache.camel.model.BeanDefinition;
import org.apache.camel.model.KameletDefinition;
import org.apache.camel.model.ScriptDefinition;
import org.apache.camel.model.ThrowExceptionDefinition;
+import org.apache.camel.model.TransformDataTypeDefinition;
import org.apache.camel.model.language.MethodCallExpression;
import org.apache.camel.processor.DisabledProcessor;
import org.apache.camel.reifier.ProcessorReifier;
@@ -141,6 +142,19 @@ public class StubEipReifier {
}
return null;
});
+
+ ProcessorReifier.registerReifier(TransformDataTypeDefinition.class,
+ (route, processorDefinition) -> {
+ if (processorDefinition instanceof
TransformDataTypeDefinition td) {
+ return new ProcessorReifier<>(route, td) {
+ @Override
+ public Processor createProcessor() throws
Exception {
+ return new DisabledProcessor();
+ }
+ };
+ }
+ return null;
+ });
}
}