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 b3a18e0 CAMEL-16861: Cleanup and update EIP docs
b3a18e0 is described below
commit b3a18e0ba1945f49b6953a2791d4f77dbb4d92ca
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Oct 14 16:14:42 2021 +0200
CAMEL-16861: Cleanup and update EIP docs
---
.../modules/eips/pages/message-translator.adoc | 2 +-
.../main/docs/modules/eips/pages/setBody-eip.adoc | 60 +++++++++++++++-------
.../docs/modules/eips/pages/transform-eip.adoc | 14 +++--
3 files changed, 53 insertions(+), 23 deletions(-)
diff --git
a/core/camel-core-engine/src/main/docs/modules/eips/pages/message-translator.adoc
b/core/camel-core-engine/src/main/docs/modules/eips/pages/message-translator.adoc
index e8046c6..b030646 100644
---
a/core/camel-core-engine/src/main/docs/modules/eips/pages/message-translator.adoc
+++
b/core/camel-core-engine/src/main/docs/modules/eips/pages/message-translator.adoc
@@ -9,7 +9,7 @@ image::eip/MessageTranslator.gif[image]
The Message Translator can be done in different ways in Camel:
-* Using xref:transform-eip.adoc[Transform] in the DSL
+* Using xref:transform-eip.adoc[Transform] or xref:setBody-eip.adoc[Set Body]
in the DSL
* Calling a xref:latest@manual:ROOT:processor.adoc[Processor] or
xref:latest@manual:ROOT:bean-integration.adoc[bean]
to perform the transformation
* Using template-based xref:components::index.adoc[Components], with the
template being the source for how the message is translated
diff --git
a/core/camel-core-engine/src/main/docs/modules/eips/pages/setBody-eip.adoc
b/core/camel-core-engine/src/main/docs/modules/eips/pages/setBody-eip.adoc
index 0036ec7..0614cb6 100644
--- a/core/camel-core-engine/src/main/docs/modules/eips/pages/setBody-eip.adoc
+++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/setBody-eip.adoc
@@ -5,7 +5,23 @@
:since:
:supportlevel: Stable
-The SetBody EIP allows you to set the body of your exchange.
+Camel supports the
+http://www.enterpriseintegrationpatterns.com/MessageTranslator.html[Message
+Translator] from the xref:enterprise-integration-patterns.adoc[EIP
+patterns].
+
+image::eip/MessageTranslator.gif[image]
+
+The xref:message-translator.adoc[Message Translator] can be done in different
ways in Camel:
+
+* Using xref:transform-eip.adoc[Transform] or xref:setBody-eip.adoc[Set Body]
in the DSL
+* Calling a xref:latest@manual:ROOT:processor.adoc[Processor] or
xref:latest@manual:ROOT:bean-integration.adoc[bean]
+to perform the transformation
+* Using template-based xref:components::index.adoc[Components], with the
template being the source for how the message is translated
+* Messages can also be transformed using
xref:latest@manual:ROOT:data-format.adoc[Data Format]
+to marshal and unmarshal messages in different encodings.
+
+This page is documenting the first approach by using Set Body EIP.
== Options
@@ -15,29 +31,37 @@ include::partial$eip-options.adoc[]
== Examples
-The following example shows how to use the SetBody EIP
+=== Using Set Body EIP
+
+You can use a xref:setBody-eip.adoc[Set Body] which uses an
+xref:latest@manual:ROOT:expression.adoc[Expression] to do the transformation:
+
+In the example below we prepend Hello to the message body using the
+xref:components:languages:simple-language.adoc[Simple] language:
[source,java]
----
-RouteBuilder builder = new RouteBuilder() {
- public void configure() {
- from("direct:a")
- .setBody(constant("test"))
- .to("direct:b");
- }
-};
+from("direct:cheese")
+ .setBody(simple("Hello ${body}"))
+ .to("log:hello");
----
-
-And the same example using XML:
+And in XML DSL:
[source,xml]
----
-<camelContext xmlns="http://camel.apache.org/schema/spring">
- <route>
- <from uri="direct:a"/>
- <setBody><constant>test</constant></setBody>
- <to uri="direct:b"/>
- </route>
-</camelContext>
+<route>
+ <from uri="direct:cheese"/>
+ <setBody>
+ <simple>Hello ${body}</simple>
+ </setBody>
+ <to uri="log:hello"/>
+</route>
----
+
+=== What is the difference between Transform and Set Body
+
+The Transform EIP always sets the result on the OUT message body.
+
+Set Body sets the result accordingly to the
xref:latest@manual:ROOT:exchange-pattern.adoc[Exchange Pattern]
+on the `Exchange`.
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 6d6b2a8..c3e4eb1 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
@@ -12,9 +12,9 @@ patterns].
image::eip/MessageTranslator.gif[image]
-The Message Translator can be done in different ways in Camel:
+The xref:message-translator.adoc[Message Translator] can be done in different
ways in Camel:
-* Using Transform EIP in the DSL
+* Using xref:transform-eip.adoc[Transform] or xref:setBody-eip.adoc[Set Body]
in the DSL
* Calling a xref:latest@manual:ROOT:processor.adoc[Processor] or
xref:latest@manual:ROOT:bean-integration.adoc[bean]
to perform the transformation
* Using template-based xref:components::index.adoc[Components], with the
template being the source for how the message is translated
@@ -49,11 +49,17 @@ And in XML DSL:
[source,xml]
----
<route>
- <from uri="activemq:cheese"/>
+ <from uri="direct:cheese"/>
<transform>
<simple>Hello ${body}</simple>
</transform>
- <to uri="activemq:wine"/>
+ <to uri="log:hello"/>
</route>
----
+=== What is the difference between Transform and Set Body
+
+The Transform EIP always sets the result on the OUT message body.
+
+Set Body sets the result accordingly to the
xref:latest@manual:ROOT:exchange-pattern.adoc[Exchange Pattern]
+on the `Exchange`.