Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 59F1A160ADD for ; Fri, 28 Oct 2016 10:53:06 +0200 (CEST) Received: (qmail 77546 invoked by uid 500); 28 Oct 2016 08:53:05 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 77531 invoked by uid 99); 28 Oct 2016 08:53:05 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Oct 2016 08:53:05 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0496FEFE5E; Fri, 28 Oct 2016 08:53:04 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: acosentino@apache.org To: commits@camel.apache.org Date: Fri, 28 Oct 2016 08:53:04 -0000 Message-Id: <787d28768f5f478f8fe1783dba80b3b4@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/3] camel git commit: Added Content Based Router docs to Gitbook archived-at: Fri, 28 Oct 2016 08:53:07 -0000 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 Authored: Fri Oct 28 10:45:35 2016 +0200 Committer: Andrea Cosentino 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] +------------------------------------------------------------------------------------------- + + + + + + $foo = 'bar' + + + + $foo = 'cheese' + + + + + + + + +------------------------------------------------------------------------------------------- + +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