Repository: camel Updated Branches: refs/heads/master 8e42a7bd3 -> cc4ccd4d6
Polished the docs a bit Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/cc4ccd4d Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/cc4ccd4d Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/cc4ccd4d Branch: refs/heads/master Commit: cc4ccd4d6d1648b073d96d4da66111906f0ff1b4 Parents: 8e42a7b Author: Claus Ibsen <davscl...@apache.org> Authored: Thu Apr 13 16:25:53 2017 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Thu Apr 13 16:25:53 2017 +0200 ---------------------------------------------------------------------- .../src/main/docs/eips/aggregate-eip.adoc | 2 +- camel-core/src/main/docs/eips/choice-eip.adoc | 91 ++++++++++++++++++++ camel-core/src/main/docs/eips/choice-eip.mv | 79 ----------------- .../apache/camel/model/AggregateDefinition.java | 16 +++- 4 files changed, 104 insertions(+), 84 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/cc4ccd4d/camel-core/src/main/docs/eips/aggregate-eip.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/eips/aggregate-eip.adoc b/camel-core/src/main/docs/eips/aggregate-eip.adoc index 9d87dde..19c5d9d 100644 --- a/camel-core/src/main/docs/eips/aggregate-eip.adoc +++ b/camel-core/src/main/docs/eips/aggregate-eip.adoc @@ -26,7 +26,7 @@ The Aggregate EIP supports 25 options which are listed below: |======================================================================= | Name | Java Type | Description | correlationExpression | NamespaceAwareExpression | *Required* The expression used to calculate the correlation key to use for aggregation. The Exchange which has the same correlation key is aggregated together. If the correlation key could not be evaluated an Exception is thrown. You can disable this by using the ignoreBadCorrelationKeys option. -| completionPredicate | NamespaceAwareExpression | Sets the predicate used to determine if the aggregation is completed with a fluent builder +| completionPredicate | NamespaceAwareExpression | A Predicate to indicate when an aggregated exchange is complete. If this is not specified and the AggregationStrategy object implements Predicate the aggregationStrategy object will be used as the completionPredicate. | completionTimeout | NamespaceAwareExpression | Time in millis that an aggregated exchange should be inactive before its complete (timeout). This option can be set as either a fixed value or using an Expression which allows you to evaluate a timeout dynamically - will use Long as result. If both are set Camel will fallback to use the fixed value if the Expression result was null or 0. You cannot use this option together with completionInterval only one of the two can be used. | completionSize | NamespaceAwareExpression | Number of messages aggregated before the aggregation is complete. This option can be set as either a fixed value or using an Expression which allows you to evaluate a size dynamically - will use Integer as result. If both are set Camel will fallback to use the fixed value if the Expression result was null or 0. | optimisticLockRetryPolicy | OptimisticLockRetryPolicyDefinition | Allows to configure retry settings when using optimistic locking. http://git-wip-us.apache.org/repos/asf/camel/blob/cc4ccd4d/camel-core/src/main/docs/eips/choice-eip.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/eips/choice-eip.adoc b/camel-core/src/main/docs/eips/choice-eip.adoc new file mode 100644 index 0000000..dd7df33 --- /dev/null +++ b/camel-core/src/main/docs/eips/choice-eip.adoc @@ -0,0 +1,91 @@ +## Choice EIP + +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] + +### Choice options + +// eip options: START +The Choice EIP supports 2 options which are listed below: + + +[width="100%",cols="3,1m,6",options="header"] +|======================================================================= +| Name | Java Type | Description +| whenClauses | List | Sets the when clauses +| otherwise | OtherwiseDefinition | Sets the otherwise node +|======================================================================= +// 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 + +*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] + +#### 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/cc4ccd4d/camel-core/src/main/docs/eips/choice-eip.mv ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/eips/choice-eip.mv b/camel-core/src/main/docs/eips/choice-eip.mv deleted file mode 100644 index 809b332..0000000 --- a/camel-core/src/main/docs/eips/choice-eip.mv +++ /dev/null @@ -1,79 +0,0 @@ -[[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/cc4ccd4d/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java b/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java index 96517df..1766289 100644 --- a/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java +++ b/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java @@ -901,7 +901,9 @@ public class AggregateDefinition extends ProcessorDefinition<AggregateDefinition } /** - * Sets the predicate used to determine if the aggregation is completed + * A Predicate to indicate when an aggregated exchange is complete. + * If this is not specified and the AggregationStrategy object implements Predicate, + * the aggregationStrategy object will be used as the completionPredicate. */ public AggregateDefinition completionPredicate(@AsPredicate Predicate predicate) { checkNoCompletedPredicate(); @@ -910,7 +912,9 @@ public class AggregateDefinition extends ProcessorDefinition<AggregateDefinition } /** - * Sets the predicate used to determine if the aggregation is completed with a fluent builder + * A Predicate to indicate when an aggregated exchange is complete. + * If this is not specified and the AggregationStrategy object implements Predicate, + * the aggregationStrategy object will be used as the completionPredicate. */ @AsPredicate public PredicateClause<AggregateDefinition> completionPredicate() { @@ -920,7 +924,9 @@ public class AggregateDefinition extends ProcessorDefinition<AggregateDefinition } /** - * Sets the predicate used to determine if the aggregation is completed with a fluent builder + * A Predicate to indicate when an aggregated exchange is complete. + * If this is not specified and the AggregationStrategy object implements Predicate, + * the aggregationStrategy object will be used as the completionPredicate. */ @AsPredicate public PredicateClause<AggregateDefinition> completion() { @@ -928,7 +934,9 @@ public class AggregateDefinition extends ProcessorDefinition<AggregateDefinition } /** - * Sets the predicate used to determine if the aggregation is completed + * A Predicate to indicate when an aggregated exchange is complete. + * If this is not specified and the AggregationStrategy object implements Predicate, + * the aggregationStrategy object will be used as the completionPredicate. */ public AggregateDefinition completion(@AsPredicate Predicate predicate) { return completionPredicate(predicate);