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 74e371e CAMEL-16861: Cleanup and update EIP docs
74e371e is described below
commit 74e371e921436bb46b0198e1ff89deafedec3cd1
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Oct 14 14:54:11 2021 +0200
CAMEL-16861: Cleanup and update EIP docs
---
.../main/docs/modules/eips/pages/validate-eip.adoc | 52 +++++++++++-----------
1 file changed, 26 insertions(+), 26 deletions(-)
diff --git
a/core/camel-core-engine/src/main/docs/modules/eips/pages/validate-eip.adoc
b/core/camel-core-engine/src/main/docs/modules/eips/pages/validate-eip.adoc
index a62ec57..e72fd73 100644
--- a/core/camel-core-engine/src/main/docs/modules/eips/pages/validate-eip.adoc
+++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/validate-eip.adoc
@@ -5,11 +5,14 @@
:since:
:supportlevel: Stable
-Validate uses an expression or predicates to validate the contents of a
message.
-It is useful for ensuring that messages are valid before attempting to process
them.
-You can use the validate DSL with all kind of Predicates and Expressions.
-Validate evaluates the Predicate/Expression and if it is false a
`PredicateValidationException` is thrown.
-If it is true message processing continues.
+The Validate EIP uses an xref:latest@manual:ROOT:expression.adoc[Expression]
or xref:latest@manual:ROOT:predicate.adoc[Predicate]
+to validate the contents of a message.
+
+image::eip/MessageSelectorIcon.gif[image]
+
+This is useful for ensuring that messages are valid before attempting to
process them.
+
+When a message is *not* valid then a `PredicateValidationException` is thrown.
== Options
@@ -17,61 +20,58 @@ If it is true message processing continues.
include::partial$eip-options.adoc[]
// eip options: END
-== Samples
+=== Using Validate EIP
-The route below will read the file contents and validate them against a
regular expression.
+The route below will read the file contents and validate the message body
against a regular expression.
[source,java]
----
-from("file://inbox")
+from("file:inbox")
.validate(body(String.class).regex("^\\w{10}\\,\\d{2}\\,\\w{24}$"))
- .to("bean:MyServiceBean.processLine");
+ .to("bean:myServiceBean.processLine");
----
Validate EIP is not limited to the message body. You can also validate the
message header.
[source,java]
----
-from("file://inbox")
+from("file:inbox")
.validate(header("bar").isGreaterThan(100))
- .to("bean:MyServiceBean.processLine");
+ .to("bean:myServiceBean.processLine");
----
-You can also use validate together with simple.
+You can also use validate together with the
xref:components:languages:simple-language.adoc[Simple] language.
[source,java]
----
-from("file://inbox")
- .validate(simple("${in.header.bar} == 100"))
- .to("bean:MyServiceBean.processLine");
+from("file:inbox")
+ .validate(simple("${header.bar} > 100"))
+ .to("bean:myServiceBean.processLine");
----
-To use validate in the Spring DSL, the easiest way is to use simple
expressions.
+To use validate in the XML DSL, the easiest way is to use
+xref:components:languages:simple-language.adoc[Simple] language:
[source,xml]
----
<route>
- <from uri="file://inbox"/>
+ <from uri="file:inbox"/>
<validate>
<simple>${body} regex ^\\w{10}\\,\\d{2}\\,\\w{24}$</simple>
</validate>
- <beanRef ref="myServiceBean" method="processLine"/>
+ <to uri="bean:myServiceBean" method="processLine"/>
</route>
-
-<bean id="myServiceBean" class="com.mycompany.MyServiceBean"/>
----
-The XML DSL to validate the message header would looks like this:
+The XML DSL to validate the message header is as follows::
[source,xml]
----
<route>
- <from uri="file://inbox"/>
+ <from uri="file:inbox"/>
<validate>
- <simple>${in.header.bar} == 100</simple>
+ <simple>${header.bar} > 100</simple>
</validate>
- <beanRef ref="myServiceBean" method="processLine"/>
+ <to uri="bean:myServiceBean" method="processLine"/>
</route>
-
-<bean id="myServiceBean" class="com.mycompany.MyServiceBean"/>
----