camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [1/3] camel git commit: Added Content Based Router docs to Gitbook
Date Fri, 28 Oct 2016 08:53:04 GMT
Repository: camel
Updated Branches:
  refs/heads/master 7e2db36e7 -> 4cf3a03f3


Added Content Based Router docs to Gitbook


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/495f0810
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/495f0810
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/495f0810

Branch: refs/heads/master
Commit: 495f0810816df4b2c04132ebeaf2ec991db7cae4
Parents: 7e2db36
Author: Andrea Cosentino <ancosen@gmail.com>
Authored: Fri Oct 28 10:45:35 2016 +0200
Committer: Andrea Cosentino <ancosen@gmail.com>
Committed: Fri Oct 28 10:47:07 2016 +0200

----------------------------------------------------------------------
 .../src/main/docs/content-based-router.adoc     | 79 ++++++++++++++++++++
 docs/user-manual/en/SUMMARY.md                  |  2 +
 2 files changed, 81 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/495f0810/camel-core/src/main/docs/content-based-router.adoc
----------------------------------------------------------------------
diff --git a/camel-core/src/main/docs/content-based-router.adoc b/camel-core/src/main/docs/content-based-router.adoc
new file mode 100644
index 0000000..809b332
--- /dev/null
+++ b/camel-core/src/main/docs/content-based-router.adoc
@@ -0,0 +1,79 @@
+[[ContentBasedRouter-ContentBasedRouter]]
+Content Based Router
+^^^^^^^^^^^^^^^^^^^^
+
+The
+http://www.enterpriseintegrationpatterns.com/ContentBasedRouter.html[Content
+Based Router] from the link:enterprise-integration-patterns.html[EIP
+patterns] allows you to route messages to the correct destination based
+on the contents of the message exchanges.
+
+image:http://www.enterpriseintegrationpatterns.com/img/ContentBasedRouter.gif[image]
+
+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
+
+*Using the link:fluent-builders.html[Fluent Builders]*
+
+[source,java]
+--------------------------------------------------------
+RouteBuilder builder = new RouteBuilder() {
+    public void configure() {
+        errorHandler(deadLetterChannel("mock:error"));
+ 
+        from("direct:a")
+            .choice()
+                .when(header("foo").isEqualTo("bar"))
+                    .to("direct:b")
+                .when(header("foo").isEqualTo("cheese"))
+                    .to("direct:c")
+                .otherwise()
+                    .to("direct:d");
+    }
+};
+--------------------------------------------------------
+
+TIP: See link:why-can-i-not-use-when-or-otherwise-in-a-java-camel-route.html[Why
+can I not use when or otherwise in a Java Camel route] if you have
+problems with the Java DSL, accepting using `when` or `otherwise`.
+
+
+*Using the link:spring-xml-extensions.html[Spring XML Extensions]*
+
+[source,xml]
+-------------------------------------------------------------------------------------------
+<camelContext errorHandlerRef="errorHandler" xmlns="http://camel.apache.org/schema/spring">
+    <route>
+        <from uri="direct:a"/>
+        <choice>
+            <when>
+                <xpath>$foo = 'bar'</xpath>
+                <to uri="direct:b"/>
+            </when>
+            <when>
+                <xpath>$foo = 'cheese'</xpath>
+                <to uri="direct:c"/>
+            </when>
+            <otherwise>
+                <to uri="direct:d"/>
+            </otherwise>
+        </choice>
+    </route>
+</camelContext>
+-------------------------------------------------------------------------------------------
+
+For further examples of this pattern in use you could look at the
+http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ChoiceTest.java?view=markup[junit
+test case]
+
+[[ContentBasedRouter-UsingThisPattern]]
+Using This Pattern
+++++++++++++++++++
+
+If you would like to use this EIP Pattern then please read the
+link:getting-started.html[Getting Started], you may also find the
+link:architecture.html[Architecture] useful particularly the description
+of link:endpoint.html[Endpoint] and link:uris.html[URIs]. Then you could
+try out some of the link:examples.html[Examples] first before trying
+this pattern out.

http://git-wip-us.apache.org/repos/asf/camel/blob/495f0810/docs/user-manual/en/SUMMARY.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md
index 2233ac5..26af756 100644
--- a/docs/user-manual/en/SUMMARY.md
+++ b/docs/user-manual/en/SUMMARY.md
@@ -92,6 +92,8 @@
         * [Event Message](event-message.adoc)
         * [Return Address](return-address.adoc)
         * [Request Reply](request-reply.adoc)
+    * Message Routing
+        * [Content Based Router](content-based-router.adoc)
 
 * Community
     * FAQ


Mime
View raw message