camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [camel] 01/04: Added When EIP docs
Date Fri, 02 Mar 2018 07:26:00 GMT
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit c2f172b93508d4307c16d921a2374a8574118839
Author: Andrea Cosentino <ancosen@gmail.com>
AuthorDate: Fri Mar 2 08:13:41 2018 +0100

    Added When EIP docs
---
 camel-core/src/main/docs/eips/when-eip.adoc | 61 +++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/camel-core/src/main/docs/eips/when-eip.adoc b/camel-core/src/main/docs/eips/when-eip.adoc
new file mode 100644
index 0000000..7f3b791
--- /dev/null
+++ b/camel-core/src/main/docs/eips/when-eip.adoc
@@ -0,0 +1,61 @@
+[[when-eip]]
+== When EIP
+
+The When EIP is related to http://www.enterpriseintegrationpatterns.com/ContentBasedRouter.html[Content
+Based Router] from the link:enterprise-integration-patterns.html[EIP
+patterns]
+
+image:http://www.enterpriseintegrationpatterns.com/img/ContentBasedRouter.gif[image]
+
+=== Options
+
+// eip options: START
+The When EIP has no options.
+// eip options: END
+
+=== Examples
+
+The following example shows how to route a request from an input
+*seda:a* endpoint to either *seda:b*, *seda:c* or *seda:d* depending on
+the evaluation of various link:predicate.html[Predicate] expressions
+
+[source,java]
+----
+RouteBuilder builder = new RouteBuilder() {
+    public void configure() {
+        from("direct:a")
+            .choice()
+                .when(simple("${header.foo} == 'bar'"))
+                    .to("direct:b")
+                .when(simple("${header.foo} == 'cheese'"))
+                    .to("direct:c")
+                .otherwise()
+                    .to("direct:d");
+    }
+};
+----
+
+
+And the same example using XML:
+
+[source,xml]
+----
+<camelContext xmlns="http://camel.apache.org/schema/spring">
+    <route>
+        <from uri="direct:a"/>
+        <choice>
+            <when>
+                <simple>${header.foo} == 'bar'</simple>
+                <to uri="direct:b"/>
+            </when>
+            <when>
+                <simple>${header.foo} == 'cheese'</simple>
+                <to uri="direct:c"/>
+            </when>
+            <otherwise>
+                <to uri="direct:d"/>
+            </otherwise>
+        </choice>
+    </route>
+</camelContext>
+----

-- 
To stop receiving notification emails like this one, please contact
acosentino@apache.org.

Mime
View raw message