CAMEL-11786: Migrate docs to more correct ascii doc format
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9f22fab8 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9f22fab8 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9f22fab8 Branch: refs/heads/master Commit: 9f22fab8696c114af1ab8ac16805ba8783865570 Parents: 4f4f2e4 Author: Claus Ibsen <davscl...@apache.org> Authored: Tue Sep 19 10:58:28 2017 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Tue Sep 19 10:58:28 2017 +0200 ---------------------------------------------------------------------- camel-core/src/main/docs/bean-component.adoc | 14 +- camel-core/src/main/docs/bean-language.adoc | 12 +- camel-core/src/main/docs/binding-component.adoc | 10 +- camel-core/src/main/docs/browse-component.adoc | 8 +- camel-core/src/main/docs/class-component.adoc | 10 +- camel-core/src/main/docs/constant-language.adoc | 6 +- .../src/main/docs/controlbus-component.adoc | 18 +- .../src/main/docs/dataformat-component.adoc | 8 +- camel-core/src/main/docs/dataset-component.adoc | 26 +- camel-core/src/main/docs/direct-component.adoc | 8 +- .../src/main/docs/direct-vm-component.adoc | 8 +- .../src/main/docs/eips/aggregate-eip.adoc | 830 ++++--------------- camel-core/src/main/docs/eips/bean-eip.adoc | 17 +- camel-core/src/main/docs/eips/choice-eip.adoc | 8 +- .../src/main/docs/eips/circuitBreaker-eip.adoc | 4 +- .../main/docs/eips/customLoadBalancer-eip.adoc | 2 +- .../src/main/docs/eips/dead-letter-channel.adoc | 45 +- camel-core/src/main/docs/eips/delay-eip.adoc | 18 +- .../src/main/docs/eips/dynamicRouter-eip.adoc | 16 +- camel-core/src/main/docs/eips/enrich-eip.adoc | 22 +- camel-core/src/main/docs/eips/filter-eip.adoc | 12 +- camel-core/src/main/docs/eips/hystrix-eip.adoc | 10 +- .../docs/eips/hystrixConfiguration-eip.adoc | 2 +- .../src/main/docs/eips/loadBalance-eip.adoc | 20 +- camel-core/src/main/docs/eips/log-eip.adoc | 16 +- camel-core/src/main/docs/eips/loop-eip.adoc | 18 +- camel-core/src/main/docs/eips/random-eip.adoc | 2 +- .../src/main/docs/eips/recipientList-eip.adoc | 44 +- .../src/main/docs/eips/resequence-eip.adoc | 28 +- .../src/main/docs/eips/routingSlip-eip.adoc | 20 +- camel-core/src/main/docs/eips/sample-eip.adoc | 14 +- camel-core/src/main/docs/eips/script-eip.adoc | 12 +- .../src/main/docs/eips/serviceCall-eip.adoc | 14 +- camel-core/src/main/docs/eips/sort-eip.adoc | 10 +- camel-core/src/main/docs/eips/split-eip.adoc | 40 +- camel-core/src/main/docs/eips/throttle-eip.adoc | 20 +- camel-core/src/main/docs/eips/validate-eip.adoc | 10 +- .../main/docs/exchangeProperty-language.adoc | 6 +- camel-core/src/main/docs/file-component.adoc | 82 +- camel-core/src/main/docs/file-language.adoc | 16 +- camel-core/src/main/docs/gzip-dataformat.adoc | 8 +- camel-core/src/main/docs/header-language.adoc | 6 +- .../src/main/docs/language-component.adoc | 12 +- camel-core/src/main/docs/log-component.adoc | 20 +- camel-core/src/main/docs/mock-component.adoc | 28 +- .../src/main/docs/properties-component.adoc | 62 +- camel-core/src/main/docs/ref-component.adoc | 10 +- camel-core/src/main/docs/ref-language.adoc | 6 +- .../src/main/docs/rest-api-component.adoc | 38 +- camel-core/src/main/docs/rest-component.adoc | 16 +- camel-core/src/main/docs/return-address.adoc | 4 +- .../src/main/docs/scheduler-component.adoc | 16 +- camel-core/src/main/docs/seda-component.adoc | 20 +- .../src/main/docs/serialization-dataformat.adoc | 4 +- camel-core/src/main/docs/simple-language.adoc | 28 +- camel-core/src/main/docs/string-dataformat.adoc | 8 +- camel-core/src/main/docs/stub-component.adoc | 8 +- camel-core/src/main/docs/test-component.adoc | 8 +- camel-core/src/main/docs/timer-component.adoc | 16 +- camel-core/src/main/docs/tokenize-language.adoc | 2 +- .../src/main/docs/validator-component.adoc | 10 +- camel-core/src/main/docs/vm-component.adoc | 8 +- camel-core/src/main/docs/xpath-language.adoc | 40 +- camel-core/src/main/docs/xslt-component.adoc | 24 +- .../src/main/docs/xtokenize-language.adoc | 2 +- camel-core/src/main/docs/zip-dataformat.adoc | 8 +- 66 files changed, 691 insertions(+), 1207 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/9f22fab8/camel-core/src/main/docs/bean-component.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/bean-component.adoc b/camel-core/src/main/docs/bean-component.adoc index cafda99..c4ee066 100644 --- a/camel-core/src/main/docs/bean-component.adoc +++ b/camel-core/src/main/docs/bean-component.adoc @@ -4,7 +4,7 @@ The *bean:* component binds beans to Camel message exchanges. -### URI format +=== URI format [source,java] --------------------- @@ -14,7 +14,7 @@ bean:beanName[?options] Where *beanID* can be any string which is used to look up the bean in the link:registry.html[Registry] -### Options +=== Options // component options: START @@ -57,7 +57,7 @@ with the following path and query parameters: You can append query options to the URI in the following format, `?option=value&option=value&...` -### Using +=== Using The object instance that is used to consume messages must be explicitly registered with the link:registry.html[Registry]. For example, if you @@ -91,7 +91,7 @@ And the same route using Spring DSL: </route> ---------------------------- -### Bean as endpoint +=== Bean as endpoint Camel also supports invoking link:bean.html[Bean] as an Endpoint. In the route below: @@ -104,7 +104,7 @@ Camel will use link:bean-binding.html[Bean Binding] to invoke the `sayHello` method, by converting the Exchange's In body to the `String` type and storing the output of the method on the Exchange Out body. -### Java DSL bean syntax +=== Java DSL bean syntax Java DSL comes with syntactic sugar for the link:bean.html[Bean] component. Instead of specifying the bean explicitly as the endpoint @@ -136,7 +136,7 @@ from("direct:start").bean(new ExampleBean(), "methodName"); from("direct:start").bean(ExampleBean.class); --------------------------------------------------------------- -### Bean Binding +=== Bean Binding How bean methods to be invoked are chosen (if they are not specified explicitly through the *method* parameter) and how parameter values are @@ -145,7 +145,7 @@ link:bean-binding.html[Bean Binding] mechanism which is used throughout all of the various link:bean-integration.html[Bean Integration] mechanisms in Camel. -### See Also +=== See Also * link:configuring-camel.html[Configuring Camel] * link:component.html[Component] http://git-wip-us.apache.org/repos/asf/camel/blob/9f22fab8/camel-core/src/main/docs/bean-language.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/bean-language.adoc b/camel-core/src/main/docs/bean-language.adoc index b3b4c7f..e5b4c1e 100644 --- a/camel-core/src/main/docs/bean-language.adoc +++ b/camel-core/src/main/docs/bean-language.adoc @@ -20,7 +20,7 @@ link:message.html[Message] Exchange to the method parameters; so you can annotate the bean to extract headers or other expressions such as link:xpath.html[XPath] or link:xquery.html[XQuery] from the message. -### Bean Options +=== Bean Options // language options: START The Bean method language supports 5 options which are listed below. @@ -39,7 +39,7 @@ The Bean method language supports 5 options which are listed below. // language options: END -### Using Bean Expressions from the Java DSL +=== Using Bean Expressions from the Java DSL [source,java] ---------------------------------------------- @@ -48,7 +48,7 @@ from("activemq:topic:OrdersTopic"). to("activemq:BigSpendersQueue"); ---------------------------------------------- -### Using Bean Expressions from XML +=== Using Bean Expressions from XML [source,xml] -------------------------------------------------- @@ -66,7 +66,7 @@ from("activemq:topic:OrdersTopic"). Note, the `bean` attribute of the method expression element is now deprecated. You should now make use of `ref` attribute instead. -### Writing the expression bean +=== Writing the expression bean The bean in the above examples is just any old Java Bean with a method called isGoldCustomer() that returns some object that is easily @@ -102,7 +102,7 @@ So you can bind parameters of the method to the Exchange, the link:message.html[Message] or individual headers, properties, the body or other expressions. -### Non registry beans +=== Non registry beans The link:bean-language.html[Bean Language] also supports invoking beans that isn't registered in the link:registry.html[Registry]. This is @@ -160,6 +160,6 @@ Which also can be done in a bit shorter and nice way: to("activemq:BigSpendersQueue"); ------------------------------------------------------ -### Dependencies +=== Dependencies The Bean language is part of *camel-core*. http://git-wip-us.apache.org/repos/asf/camel/blob/9f22fab8/camel-core/src/main/docs/binding-component.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/binding-component.adoc b/camel-core/src/main/docs/binding-component.adoc index 15c3e79..b4a11c1 100644 --- a/camel-core/src/main/docs/binding-component.adoc +++ b/camel-core/src/main/docs/binding-component.adoc @@ -16,7 +16,7 @@ provide a way of wrapping Camel endpoints with contracts inside the Camel framework itself; so you can use them easily inside any Camel route. -### Options +=== Options // component options: START @@ -56,7 +56,7 @@ with the following path and query parameters: // endpoint options: END -### Using Bindings +=== Using Bindings A Binding is currently a bean which defines the contract (though we'll hopefully add bindings to the Camel DSL). @@ -64,7 +64,7 @@ hopefully add bindings to the Camel DSL). There are a few approaches to defining a bound endpoint (i.e. an endpoint bound with a Binding). -### Using the binding URI +=== Using the binding URI You can prefix any endpoint URI with *binding:nameOfBinding:* where _nameOfBinding_ is the name of the Binding bean in your registry. @@ -78,7 +78,7 @@ Here we are using the "jaxb" binding which may, for example, use the JAXB link:data-format.html[Data Format] to marshal and unmarshal messages. -### Using a BindingComponent +=== Using a BindingComponent There is a link:component.html[Component] called BindingComponent which can be configured in your link:registry.html[Registry] by dependency @@ -105,7 +105,7 @@ which would be using the queueus "foo.myQueue" and "foo.anotherQueue" and would use the given Jackson link:data-format.html[Data Format] to marshal on and off the queue. -### When to use Bindings +=== When to use Bindings If you only use an endpoint once in a single route; a binding may actually be more complex and more work than just using the 'raw' http://git-wip-us.apache.org/repos/asf/camel/blob/9f22fab8/camel-core/src/main/docs/browse-component.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/browse-component.adoc b/camel-core/src/main/docs/browse-component.adoc index c34ec49..8d93760 100644 --- a/camel-core/src/main/docs/browse-component.adoc +++ b/camel-core/src/main/docs/browse-component.adoc @@ -7,7 +7,7 @@ link:browsableendpoint.html[BrowsableEndpoint] which can be useful for testing, visualisation tools or debugging. The exchanges sent to the endpoint are all available to be browsed. -### URI format +=== URI format [source,java] ------------------------- @@ -17,7 +17,7 @@ browse:someName[?options] Where *someName* can be any string to uniquely identify the endpoint. -### Options +=== Options // component options: START @@ -56,7 +56,7 @@ with the following path and query parameters: // endpoint options: END -### Sample +=== Sample In the route below, we insert a `browse:` component to be able to browse the Exchanges that are passing through: @@ -84,7 +84,7 @@ We can now inspect the received exchanges from within the Java code: } -------------------------------------------------------------------------------------------------------- -### See Also +=== See Also * link:configuring-camel.html[Configuring Camel] * link:component.html[Component] http://git-wip-us.apache.org/repos/asf/camel/blob/9f22fab8/camel-core/src/main/docs/class-component.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/class-component.adoc b/camel-core/src/main/docs/class-component.adoc index 4473548..4821225 100644 --- a/camel-core/src/main/docs/class-component.adoc +++ b/camel-core/src/main/docs/class-component.adoc @@ -7,7 +7,7 @@ in the same way as the link:bean.html[Bean] component but instead of looking up beans from a link:registry.html[Registry] it creates the bean based on the class name. -### URI format +=== URI format [source,java] ------------------------- @@ -17,7 +17,7 @@ class:className[?options] Where *className* is the fully qualified class name to create and use as bean. -### Options +=== Options // component options: START @@ -57,7 +57,7 @@ with the following path and query parameters: // endpoint options: END -### Using +=== Using You simply use the *class* component just as the link:bean.html[Bean] component but by specifying the fully qualified classname instead. + @@ -76,7 +76,7 @@ example `hello`: from("direct:start").to("class:org.apache.camel.component.bean.MyFooBean?method=hello").to("mock:result"); -------------------------------------------------------------------------------------------------------------- -### Setting properties on the created instance +=== Setting properties on the created instance In the endpoint uri you can specify properties to set on the created instance, for example if it has a `setPrefix` method: @@ -117,7 +117,7 @@ id `foo` and invoke the `setCool` method on the created instance of the TIP:See more details at the link:bean.html[Bean] component as the *class* component works in much the same way. -### See Also +=== See Also * link:configuring-camel.html[Configuring Camel] * link:component.html[Component] http://git-wip-us.apache.org/repos/asf/camel/blob/9f22fab8/camel-core/src/main/docs/constant-language.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/constant-language.adoc b/camel-core/src/main/docs/constant-language.adoc index 6c46d51..b63ad2d 100644 --- a/camel-core/src/main/docs/constant-language.adoc +++ b/camel-core/src/main/docs/constant-language.adoc @@ -5,7 +5,7 @@ The Constant Expression Language is really just a way to specify constant strings as a type of expression. -### Constant Options +=== Constant Options // language options: START @@ -21,7 +21,7 @@ The Constant language supports 1 options which are listed below. // language options: END -### Example usage +=== Example usage The setHeader element of the Spring DSL can utilize a constant expression like: @@ -48,6 +48,6 @@ And the same example using Java DSL: from("seda:a").setHeader("theHeader", constant("the value")).to("mock:b"); -------------------------------------------------------------------------- -### Dependencies +=== Dependencies The Constant language is part of *camel-core*. http://git-wip-us.apache.org/repos/asf/camel/blob/9f22fab8/camel-core/src/main/docs/controlbus-component.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/controlbus-component.adoc b/camel-core/src/main/docs/controlbus-component.adoc index d6afd98..a5dedfc 100644 --- a/camel-core/src/main/docs/controlbus-component.adoc +++ b/camel-core/src/main/docs/controlbus-component.adoc @@ -1,5 +1,5 @@ == Control Bus Component -### ControlBus +=== ControlBus *Available as of Camel version 2.11.0* @@ -26,7 +26,7 @@ link:controlbus-component.html[ControlBus Component] that allows you to send messages to a control bus link:endpoint.html[Endpoint] that reacts accordingly. -### ControlBus Component +=== ControlBus Component *Available as of Camel 2.11* @@ -45,7 +45,7 @@ controlbus:command[?options] Where *command* can be any string to identify which type of command to use. -### Commands +=== Commands [width="100%",cols="10%,90%",options="header",] |======================================================================= @@ -58,7 +58,7 @@ evaluating the message body. If there is any result from the evaluation, then the result is put in the message body. |======================================================================= -### Options +=== Options // component options: START @@ -102,9 +102,9 @@ with the following path and query parameters: You can append query options to the URI in the following format, `?option=value&option=value&...` -### Samples +=== Samples -#### Using route command +#=== Using route command The route command allows you to do common tasks on a given route very easily, for example to start a route, you can send an empty message to @@ -149,7 +149,7 @@ just omit the routeId parameter as shown below: String xml = template.requestBody("controlbus:route?action=stats", null, String.class); --------------------------------------------------------------------------------------- -#### Using link:simple.html[Simple] language +#=== Using link:simple.html[Simple] language You can use the link:simple.html[Simple] language with the control bus, for example to stop a specific route, you can send a message to the @@ -187,7 +187,7 @@ message we sent to the control bus component. TIP:You can also use other languages such as link:groovy.html[Groovy], etc. -### See Also +=== See Also * link:configuring-camel.html[Configuring Camel] * link:component.html[Component] @@ -198,7 +198,7 @@ TIP:You can also use other languages such as link:groovy.html[Groovy], etc. * link:jmx.html[JMX] Component * Using link:camel-jmx.html[JMX] with Camel -#### Using This Pattern +#=== 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 http://git-wip-us.apache.org/repos/asf/camel/blob/9f22fab8/camel-core/src/main/docs/dataformat-component.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/dataformat-component.adoc b/camel-core/src/main/docs/dataformat-component.adoc index d4dca06..f8eda87 100644 --- a/camel-core/src/main/docs/dataformat-component.adoc +++ b/camel-core/src/main/docs/dataformat-component.adoc @@ -5,7 +5,7 @@ The *dataformat:* component allows to use link:data-format.html[Data Format] as a Camel link:component.html[Component]. -### URI format +=== URI format [source,java] --------------------------------------------- @@ -18,7 +18,7 @@ then followed by the operation which must either be `marshal` or Format] in use. See the link:data-format.html[Data Format] documentation for which options it support. -### DataFormat Options +=== DataFormat Options // component options: START @@ -55,7 +55,7 @@ with the following path and query parameters: // endpoint options: END -### Samples +=== Samples For example to use the link:jaxb.html[JAXB] link:data-format.html[Data Format] we can do as follows: @@ -80,7 +80,7 @@ And in XML DSL you do: </camelContext> ----------------------------------------------------------------------- -### See Also +=== See Also * link:configuring-camel.html[Configuring Camel] * link:component.html[Component] http://git-wip-us.apache.org/repos/asf/camel/blob/9f22fab8/camel-core/src/main/docs/dataset-component.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/dataset-component.adoc b/camel-core/src/main/docs/dataset-component.adoc index eb9cf78..9d67503 100644 --- a/camel-core/src/main/docs/dataset-component.adoc +++ b/camel-core/src/main/docs/dataset-component.adoc @@ -20,7 +20,7 @@ data set is received. Camel will use the link:log.html[throughput logger] when sending dataset's. -### URI format +=== URI format [source,java] ---------------------- @@ -40,7 +40,7 @@ some implementations that can be used for testing: and `org.apache.camel.component.dataset.FileDataSet`, all of which extend `DataSetSupport`. -### Options +=== Options // component options: START @@ -97,7 +97,7 @@ with the following path and query parameters: You can append query options to the URI in the following format, `?option=value&option=value&...` -### Configuring DataSet +=== Configuring DataSet Camel will lookup in the link:registry.html[Registry] for a bean implementing the DataSet interface. So you can register your own DataSet @@ -110,7 +110,7 @@ as: </bean> -------------------------------------------------------- -### Example +=== Example For example, to test that a set of messages are sent to a queue and then consumed from the queue without losing any messages: @@ -133,12 +133,12 @@ data set is and what the messages look like etc.   -### `DataSetSupport` (abstract class) +=== `DataSetSupport` (abstract class) The DataSetSupport abstract class is a nice starting point for new DataSets, and provides some useful features to derived classes. -### Properties on DataSetSupport +=== Properties on DataSetSupport [width="100%",cols="10%,10%,10%,70%",options="header",] |======================================================================= |Property |Type |Default |Description @@ -156,11 +156,11 @@ progress. Useful for showing progress of a large load test. If < 0, then `size` / 5, if is 0 then `size`, else set to `reportCount` value. |======================================================================= -### `SimpleDataSet` +=== `SimpleDataSet` The `SimpleDataSet` extends `DataSetSupport`, and adds a default body. -### Additional Properties on SimpleDataSet +=== Additional Properties on SimpleDataSet [width="100%",cols="10%,10%,10%,70%",options="header",] |======================================================================= @@ -173,12 +173,12 @@ configure the `SimpleDataSet` to use it by setting the `outputTransformer` property. |======================================================================= -### `ListDataSet (Camel 2.17)` +=== `ListDataSet (Camel 2.17)` The List`DataSet` extends `DataSetSupport`, and adds a list of default bodies. -### Additional Properties on ListDataSet +=== Additional Properties on ListDataSet [width="100%",cols="10%,10%,10%,70%",options="header",] |======================================================================= @@ -199,12 +199,12 @@ the payload for the exchange will be selected using the modulus of the `CamelDataSetIndex % defaultBodies.size()` ) |======================================================================= -### FileDataSet (Camel 2.17) +=== FileDataSet (Camel 2.17) The `SimpleDataSet` extends `ListDataSet`, and adds support for loading the bodies from a file. -### Additional Properties on FileDataSet +=== Additional Properties on FileDataSet [width="100%",cols="10%,10%,10%,70%",options="header",] |======================================================================= @@ -216,7 +216,7 @@ the bodies from a file. the file into multiple payloads. |======================================================================= -### See Also +=== See Also * link:configuring-camel.html[Configuring Camel] * link:component.html[Component] http://git-wip-us.apache.org/repos/asf/camel/blob/9f22fab8/camel-core/src/main/docs/direct-component.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/direct-component.adoc b/camel-core/src/main/docs/direct-component.adoc index 96b544d..3c82183 100644 --- a/camel-core/src/main/docs/direct-component.adoc +++ b/camel-core/src/main/docs/direct-component.adoc @@ -15,7 +15,7 @@ TIP:*Connection to other camel contexts* The link:vm.html[VM] component provides connections between Camel contexts as long they run in the same *JVM*. -### URI format +=== URI format [source,text] ------------------------- @@ -24,7 +24,7 @@ direct:someName[?options] Where *someName* can be any string to uniquely identify the endpoint -### Options +=== Options @@ -78,7 +78,7 @@ with the following path and query parameters: // endpoint options: END -### Samples +=== Samples In the route below we use the direct component to link the two routes together: @@ -114,7 +114,7 @@ And the sample using spring DSL: See also samples from the link:seda.html[SEDA] component, how they can be used together. -### See Also +=== See Also * link:configuring-camel.html[Configuring Camel] * link:component.html[Component] http://git-wip-us.apache.org/repos/asf/camel/blob/9f22fab8/camel-core/src/main/docs/direct-vm-component.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/direct-vm-component.adoc b/camel-core/src/main/docs/direct-vm-component.adoc index cf3a49e..d000a08 100644 --- a/camel-core/src/main/docs/direct-vm-component.adoc +++ b/camel-core/src/main/docs/direct-vm-component.adoc @@ -26,7 +26,7 @@ Transactions - Tx. image:direct-vm.data/camel-direct-vm.png[image] -### URI format +=== URI format [source,java] ------------------ @@ -35,7 +35,7 @@ direct-vm:someName Where *someName* can be any string to uniquely identify the endpoint -### Options +=== Options @@ -93,7 +93,7 @@ with the following path and query parameters: // endpoint options: END -### Samples +=== Samples In the route below we use the direct component to link the two routes together: @@ -131,7 +131,7 @@ And the sample using spring DSL: </route> -------------------------------------------------- -### See Also +=== See Also * link:configuring-camel.html[Configuring Camel] * link:component.html[Component] http://git-wip-us.apache.org/repos/asf/camel/blob/9f22fab8/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 677565e..e7bf61c 100644 --- a/camel-core/src/main/docs/eips/aggregate-eip.adoc +++ b/camel-core/src/main/docs/eips/aggregate-eip.adoc @@ -1,7 +1,4 @@ -## Aggregate EIP - -*This applies for Camel version 2.3 or newer. If you use an older -version then use this link:aggregator.html[Aggregator] link instead.* +== Aggregate EIP The http://www.enterpriseintegrationpatterns.com/Aggregator.html[Aggregator] @@ -16,14 +13,14 @@ all messages into a single message, just use a constant expression. An AggregationStrategy is used to combine all the message exchanges for a single correlation key into a single message exchange. -### Aggregator options +=== Aggregator options // eip options: START The Aggregate EIP supports 26 options which are listed below: [width="100%",cols="3,1m,6",options="header"] -|======================================================================= +|=== | 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 | 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. @@ -51,10 +48,10 @@ The Aggregate EIP supports 26 options which are listed below: | forceCompletionOnStop | Boolean | Indicates to complete all current aggregated exchanges when the context is stopped | completeAllOnStop | Boolean | Indicates to wait to complete all current and partial (pending) aggregated exchanges when the context is stopped. This also means that we will wait for all pending exchanges which are stored in the aggregation repository to complete so the repository is empty before we can stop. You may want to enable this when using the memory based aggregation repository that is memory based only and do not store data on disk. When this option is enabled then the aggregator is waiting to complete all those exchanges before its stopped when stopping CamelContext or the route using it. | aggregateControllerRef | String | To use a org.apache.camel.processor.aggregate.AggregateController to allow external sources to control this aggregator. -|======================================================================= +|=== // eip options: END -### About AggregationStrategy +=== About AggregationStrategy The `AggregationStrategy` is used for aggregating the old (lookup by its correlation id) and the new exchanges together into a single exchange. @@ -67,11 +64,11 @@ use. Notice the aggregation strategy is a mandatory option and must be provided to the aggregator. -Here are a few example AggregationStrategy implementations that should +Here are a few example `AggregationStrategy` implementations that should help you create your own custom strategy. [source,java] ---------------------------------------------------------------------------- +---- //simply combines Exchange String body values using '+' as a delimiter class StringAggregationStrategy implements AggregationStrategy { @@ -105,9 +102,9 @@ class ArrayListAggregationStrategy implements AggregationStrategy { } } } ---------------------------------------------------------------------------- +---- -### About completion +=== About completion When aggregation link:exchange.html[Exchange]s at some point you need to indicate that the aggregated exchanges is complete, so they can be send @@ -148,7 +145,7 @@ be used at the same time. Notice the completion is a mandatory option and must be provided to the aggregator. If not provided Camel will thrown an Exception on startup. -### Pre-completion mode +=== Pre-completion mode *available as of Camel 2.16* @@ -161,7 +158,7 @@ implement `PreCompletionAwareAggregationStrategy` which has a `preComplete` method: [source,java] ----------------------------------------------------------------------------------------------------------------------- +---- /** * Determines if the aggregation should complete the current group, and start a new group, or the aggregation * should continue using the current group. @@ -171,7 +168,7 @@ a `preComplete` method: * @return <tt>true</tt> to complete current group and start a new group, or <tt>false</tt> to keep using current */ boolean preComplete(Exchange oldExchange, Exchange newExchange); ----------------------------------------------------------------------------------------------------------------------- +---- If the preComplete method returns true, then the existing groups is completed (without aggregating the incoming exchange (newExchange). And @@ -188,7 +185,7 @@ completions consumer etc) * eagerCheckCompletion is implied as true, but the option has no effect -### Persistent AggregationRepository +=== Persistent AggregationRepository The aggregator provides a pluggable repository which you can implement your own `org.apache.camel.spi.AggregationRepository`. + @@ -196,7 +193,7 @@ your own `org.apache.camel.spi.AggregationRepository`. + link:hawtdb.html[HawtDB], link:leveldb.html[LevelDB], or link:sql-component.html[SQL Component] components. -### Using TimeoutAwareAggregationStrategy +=== Using TimeoutAwareAggregationStrategy *Available as of Camel 2.9.2* @@ -207,7 +204,7 @@ total parameters will be -1, and the timeout parameter will be provided only if configured as a fixed value. You must *not* throw any exceptions from the `timeout` method. -### Using CompletionAwareAggregationStrategy +=== Using CompletionAwareAggregationStrategy *Available as of Camel 2.9.3* @@ -218,7 +215,7 @@ allows you to do any last minute custom logic such as to cleanup some resources, or additional work on the exchange as it's now completed. + You must *not* throw any exceptions from the `onCompletion` method. -### Completing current group decided from the AggregationStrategy +=== Completing current group decided from the AggregationStrategy *Available as of Camel 2.15* @@ -232,7 +229,7 @@ group if the message body size is larger than 5. This is done by setting the property Exchange.AGGREGATION_COMPLETE_CURRENT_GROUP to true. [source,java] -------------------------------------------------------------------------------------------- +---- public final class MyCompletionStrategy implements AggregationStrategy { @Override public Exchange aggregate(Exchange oldExchange, Exchange newExchange) { @@ -248,10 +245,11 @@ the property Exchange.AGGREGATION_COMPLETE_CURRENT_GROUP to true. return oldExchange; } } -------------------------------------------------------------------------------------------- +----  -### Manually Force the Completion of All Aggregated Exchanges Immediately + +=== Manually Force the Completion of All Aggregated Exchanges Immediately *Available as of Camel 2.9* + You can manually trigger completion of all current aggregated exchanges @@ -265,7 +263,7 @@ be processed otherwise. Exchange.AGGREGATION_COMPLETE_ALL_GROUPS_INCLUSIVE to true to trigger completion of all groups after processing the current message. -### Using a List<V> in AggregationStrategy +=== Using a List<V> in AggregationStrategy *Available as of Camel 2.11* @@ -279,7 +277,7 @@ the message body. For example to aggregate a List<Integer> you can extend this class as shown below, and implement the `getValue` method: -### Using AggregateController +=== Using AggregateController *Available as of Camel 2.16* @@ -289,28 +287,28 @@ be used to force completing groups of exchanges, or query its current runtime statistics. The aggregator provides a default implementation if no custom have been -configured, which can be accessed -using `getAggregateController()` method. Though it may be easier to -configure a controller in the route using aggregateController as shown -below: +configured, which can be accessed using `getAggregateController()` method. +Though it may be easier to configure a controller in the route using +`aggregateController` as shown below: [source,java] ----------------------------------------------------------------------------------------------- +---- private AggregateController controller = new DefaultAggregateController(); - + from("direct:start") - .aggregate(header("id"), new MyAggregationStrategy()).completionSize(10).id("myAggregator") + .aggregate(header("id"), new MyAggregationStrategy()) + .completionSize(10).id("myAggregator") .aggregateController(controller) .to("mock:aggregated"); ----------------------------------------------------------------------------------------------- +---- Then there is API on AggregateController to force completion. For example to complete a group with key foo [source,java] ------------------------------------------------------- +---- int groups = controller.forceCompletionOfGroup("foo"); ------------------------------------------------------- +---- The number return would be the number of groups completed. In this case it would be 1 if the foo group existed and was completed. If foo does @@ -319,22 +317,21 @@ not exists then 0 is returned. There is also an api to complete all groups [source,java] ------------------------------------------------------ +---- int groups = controller.forceCompletionOfAllGroups(); ------------------------------------------------------ - - +---- To configure this from XML DSL -[source,java] ----------------------------------------------------------------------------------------------------------- +[source,xml] +---- <bean id="myController" class="org.apache.camel.processor.aggregate.DefaultAggregateController"/>  <camelContext xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="direct:start"/> - <aggregate strategyRef="myAppender" completionSize="10" aggregateControllerRef="myController"> + <aggregate strategyRef="myAppender" completionSize="10" + aggregateControllerRef="myController"> <correlationExpression> <header>id</header> </correlationExpression> @@ -342,29 +339,27 @@ To configure this from XML DSL </aggregate> </route> </camelContext> ----------------------------------------------------------------------------------------------------------- - - +---- There is also JMX API on the aggregator which is available under the processors node in the Camel JMX tree. -### Using GroupedExchanges +=== Using GroupedExchanges In the route below we group all the exchanges together using `groupExchanges()`: [source,java] --------------------------------------------------------------------------------------------------- - from("direct:start") - // aggregate all using same expression - .aggregate(constant(true)) - // wait for 0.5 seconds to aggregate - .completionTimeout(500L) - // group the exchanges so we get one single exchange containing all the others - .groupExchanges() - .to("mock:result"); --------------------------------------------------------------------------------------------------- +---- +from("direct:start") + // aggregate all using same expression + .aggregate(constant(true)) + // wait for 0.5 seconds to aggregate + .completionTimeout(500L) + // group the exchanges so we get one single exchange containing all the others + .groupExchanges() + .to("mock:result"); +---- As a result we have one outgoing link:exchange.html[Exchange] being routed the the "mock:result" endpoint. The exchange is a holder @@ -373,19 +368,19 @@ containing all the incoming Exchanges. + property on the outgoing exchange as shown: [source,java] --------------------------------------------------------------------------------- +---- List<Exchange> grouped = out.getProperty(Exchange.GROUPED_EXCHANGE, List.class); --------------------------------------------------------------------------------- +---- From *Camel 2.13* onwards this behavior has changed to store these exchanges directly on the message body which is more intuitive: [source,java] --------------------------------------------------------------- +---- List<Exchange> grouped = exchange.getIn().getBody(List.class); --------------------------------------------------------------- +---- -### Using POJOs as AggregationStrategy +=== Using POJOs as AggregationStrategy *Available as of Camel 2.12* @@ -417,11 +412,11 @@ the body of the `oldExchange`, and the 2nd is paired to the body of the `newExchange`: [source,java] ----------------------------------------------------- +---- public String append(String existing, String next) { return existing + next; } ----------------------------------------------------- +---- In the method below, we have only 4 parameters, so the 1st parameter is the body of the `oldExchange`, and the 2nd is the Map of the @@ -429,27 +424,28 @@ the body of the `oldExchange`, and the 2nd is the Map of the and the 4th parameter is the Map of the `newExchange` headers: [source,java] ------------------------------------------------------------------------------------------- +---- public String append(String existing, Map existingHeaders, String next, Map nextHeaders) { return existing + next; } ------------------------------------------------------------------------------------------- +---- And finally if we have 6 parameters the we also have the properties of the link:exchange.html[Exchange]s: [source,java] --------------------------------------------------------------------------------------------------------------------------------------- -public String append(String existing, Map existingHeaders, Map existingProperties, String next, Map nextHeaders, Map nextProperties) { +---- +public String append(String existing, Map existingHeaders, Map existingProperties, + String next, Map nextHeaders, Map nextProperties) { return existing + next; } --------------------------------------------------------------------------------------------------------------------------------------- +---- To use this with the link:aggregator2.html[Aggregate] EIP we can use a POJO with the aggregate logic as follows: [source,java] --------------------------------------------------------- +---- public class MyBodyAppender { public String append(String existing, String next) { @@ -457,53 +453,53 @@ public class MyBodyAppender { } } --------------------------------------------------------- +---- And then in the Camel route we create an instance of our bean, and then refer to the bean in the route using `bean` method from `org.apache.camel.util.toolbox.AggregationStrategies` as shown: [source,java] --------------------------------------------------------------------------------------- - private MyBodyAppender appender = new MyBodyAppender(); - - public void configure() throws Exception { - from("direct:start") - .aggregate(constant(true), AggregationStrategies.bean(appender, "append")) - .completionSize(3) - .to("mock:result"); - } --------------------------------------------------------------------------------------- +---- +private MyBodyAppender appender = new MyBodyAppender(); + +public void configure() throws Exception { + from("direct:start") + .aggregate(constant(true), AggregationStrategies.bean(appender, "append")) + .completionSize(3) + .to("mock:result"); +} +---- We can also provide the bean type directly: [source,java] --------------------------------------------------------------------------------------------------- - public void configure() throws Exception { - from("direct:start") - .aggregate(constant(true), AggregationStrategies.bean(MyBodyAppender.class, "append")) - .completionSize(3) - .to("mock:result"); - } --------------------------------------------------------------------------------------------------- +---- +public void configure() throws Exception { + from("direct:start") + .aggregate(constant(true), AggregationStrategies.bean(MyBodyAppender.class, "append")) + .completionSize(3) + .to("mock:result"); +} +---- And if the bean has only one method we do not need to specify the name of the method: [source,java] ----------------------------------------------------------------------------------------- - public void configure() throws Exception { - from("direct:start") - .aggregate(constant(true), AggregationStrategies.bean(MyBodyAppender.class)) - .completionSize(3) - .to("mock:result"); - } ----------------------------------------------------------------------------------------- +---- +public void configure() throws Exception { + from("direct:start") + .aggregate(constant(true), AggregationStrategies.bean(MyBodyAppender.class)) + .completionSize(3) + .to("mock:result"); +} +---- And the `append` method could be static: [source,java] ---------------------------------------------------------------- +---- public class MyBodyAppender { public static String append(String existing, String next) { @@ -511,37 +507,37 @@ public class MyBodyAppender { } } ---------------------------------------------------------------- +---- If you are using XML DSL then we need to declare a <bean> with the POJO: [source,xml] ----------------------------------------------------------- - <bean id="myAppender" class="com.foo.MyBodyAppender"/> ----------------------------------------------------------- +---- +<bean id="myAppender" class="com.foo.MyBodyAppender"/> +---- And in the Camel route we use `strategyRef` to refer to the bean by its id, and the `strategyMethodName` can be used to define the method name to call: [source,xml] ------------------------------------------------------------------------------------------------ - <camelContext xmlns="http://camel.apache.org/schema/spring"> - <route> - <from uri="direct:start"/> - <aggregate strategyRef="myAppender" strategyMethodName="append" completionSize="3"> - <correlationExpression> - <constant>true</constant> - </correlationExpression> - <to uri="mock:result"/> - </aggregate> - </route> - </camelContext> ------------------------------------------------------------------------------------------------ +---- +<camelContext xmlns="http://camel.apache.org/schema/spring"> + <route> + <from uri="direct:start"/> + <aggregate strategyRef="myAppender" strategyMethodName="append" completionSize="3"> + <correlationExpression> + <constant>true</constant> + </correlationExpression> + <to uri="mock:result"/> + </aggregate> + </route> +</camelContext> +---- When using XML DSL you must define the POJO as a <bean>. -### Aggregating when no data +=== Aggregating when no data By default when using POJOs as AggregationStrategy, then the method is *only* invoked when there is data to be aggregated (by default). You can @@ -565,47 +561,47 @@ On the bean adapter we call `setAllowNullNewExchange` to allow the new exchange to be null. [source,java] ------------------------------------------------------------------------------------------------------------ - public void configure() throws Exception { - AggregationStrategyBeanAdapter myStrategy = new AggregationStrategyBeanAdapter(appender, "append"); - myStrategy.setAllowNullOldExchange(true); - myStrategy.setAllowNullNewExchange(true); - - from("direct:start") - .pollEnrich("seda:foo", 1000, myStrategy) - .to("mock:result"); - } ------------------------------------------------------------------------------------------------------------ +---- +public void configure() throws Exception { + AggregationStrategyBeanAdapter myStrategy = new AggregationStrategyBeanAdapter(appender, "append"); + myStrategy.setAllowNullOldExchange(true); + myStrategy.setAllowNullNewExchange(true); + + from("direct:start") + .pollEnrich("seda:foo", 1000, myStrategy) + .to("mock:result"); +} +---- This can be configured a bit easier using the `beanAllowNull` method from `AggregationStrategies` as shown: [source,java] --------------------------------------------------------------------------------------------------- - public void configure() throws Exception { - from("direct:start") - .pollEnrich("seda:foo", 1000, AggregationStrategies.beanAllowNull(appender, "append")) - .to("mock:result"); - } --------------------------------------------------------------------------------------------------- +---- +public void configure() throws Exception { + from("direct:start") + .pollEnrich("seda:foo", 1000, AggregationStrategies.beanAllowNull(appender, "append")) + .to("mock:result"); +} +---- Then the `append` method in the POJO would need to deal with the situation that `newExchange` can be null: [source,java] ------------------------------------------------------------- - public class MyBodyAppender { - - public String append(String existing, String next) { - if (next == null) { - return "NewWasNull" + existing; - } else { - return existing + next; - } - } +---- +public class MyBodyAppender { + public String append(String existing, String next) { + if (next == null) { + return "NewWasNull" + existing; + } else { + return existing + next; + } } ------------------------------------------------------------- + +} +---- In the example above we use the link:content-enricher.html[Content Enricher] EIP using `pollEnrich`. The `newExchange` will be null in the @@ -621,21 +617,24 @@ In XML DSL you would configure the `strategyMethodAllowNull` option and set it to true as shown below: [source,xml] ------------------------------------------------------------------------------------------------------------------------------- - <camelContext xmlns="http://camel.apache.org/schema/spring"> - <route> - <from uri="direct:start"/> - <aggregate strategyRef="myAppender" strategyMethodName="append" strategyMethodAllowNull="true" completionSize="3"> - <correlationExpression> - <constant>true</constant> - </correlationExpression> - <to uri="mock:result"/> - </aggregate> - </route> - </camelContext> ------------------------------------------------------------------------------------------------------------------------------- +---- +<camelContext xmlns="http://camel.apache.org/schema/spring"> + <route> + <from uri="direct:start"/> + <aggregate strategyRef="myAppender" + strategyMethodName="append" + strategyMethodAllowNull="true" + completionSize="3"> + <correlationExpression> + <constant>true</constant> + </correlationExpression> + <to uri="mock:result"/> + </aggregate> + </route> +</camelContext> +---- -### Different body types +=== Different body types When for example using `strategyMethodAllowNull` as true, then the parameter types of the message bodies does not have to be the same. For @@ -644,520 +643,21 @@ example suppose we want to aggregate from a `com.foo.User` type to a this as follows: [source,java] ------------------------------------------------------ - public static final class MyUserAppender { +---- +public static final class MyUserAppender { - public List addUsers(List names, User user) { - if (names == null) { - names = new ArrayList(); - } - names.add(user.getName()); - return names; + public List addUsers(List names, User user) { + if (names == null) { + names = new ArrayList(); } + names.add(user.getName()); + return names; } ------------------------------------------------------ +} +---- Notice that the return type is a List which we want to contain the user names. The 1st parameter is the list of names, and then notice the 2nd parameter is the incoming `com.foo.User` type. -### See also - -* The link:loan-broker-example.html[Loan Broker Example] which uses an -aggregator -* -http://tmielke.blogspot.com/2009/01/using-camel-aggregator-correctly.html[Blog -post by Torsten Mielke] about using the aggregator correctly. -* The old link:aggregator.html[Aggregator] -* link:hawtdb.html[HawtDB], link:leveldb.html[LevelDB] or -link:sql-component.html[SQL Component] for persistence support -* link:aggregate-example.html[Aggregate Example] for an example -application -======= -## Aggregator -*This applies for Camel version 2.3 or newer. If you use an older version then use this link:./aggregate-old-eip.adoc[Aggregator] link instead.* - -The Aggregator from the EIP patterns allows you to combine a number of messages together into a single message. - -image:http://www.enterpriseintegrationpatterns.com/img/Aggregator.gif[image] - -A correlation link:../../../../../docs/user-manual/en/expression.adoc[Expression] is used to determine the messages which should be aggregated together. If you want to aggregate all messages into a single message, just use a constant expression. An AggregationStrategy is used to combine all the message exchanges for a single correlation key into a single message exchange. The default strategy just chooses the latest message; so its ideal for throttling messages. - -For example, imagine a stock market data system; you are receiving 30,000 messages per second; you may want to throttle down the updates as, say, a GUI cannot cope with such massive update rates. So you may want to aggregate these messages together so that within a window (defined by a maximum number of messages or a timeout), messages for the same stock are aggregated together; by just choosing the latest message and discarding the older prices. (You could apply a delta processing algorithm if you prefer to capture some of the history). - -Using the aggregator correctly:: -Torsten Mielke wrote a nice link:http://tmielke.blogspot.com/2009/01/using-camel-aggregator-correctly.html[blog entry] with his thoughts and experience on using the aggregator. Its a well worth read. - -[NOTE] -.AggregationStrategy changed in Camel 2.0 -==== -In Camel 2.0 the `AggregationStrategy` callback have been changed to also be invoked on the very first Exchange. - -On the first invocation of the `aggregate` method the `oldExchange` parameter is `null`. The reason is that we have not aggregated anything yet. -So its only the `newExchange` that has a value. Usually you just return the newExchange in this situation. But you still have the power to decide what to do, for example you can do some alternation on the exchange or remove some headers. And a more common use case is for instance to count some values from the body payload. That could be to sum up a total amount etc. -==== - -[IMPORTANT] -.BatchTimeout and CompletionPredicate -==== -You cannot use both batchTimeout and completionPredicate to trigger a completion based on either on reaching its goal first. The batch timeout will always trigger first, at that given interval. -==== - -### Using the Fluent Builders -The following example shows how to aggregate messages so that only the latest message for a specific value of the cheese header is sent: - -[source,java] --------------------------------------------------------- -// in this route we aggregate all from direct:state based on the header id cheese -from("direct:start").aggregate(header("cheese")).to("mock:result"); - -from("seda:header").setHeader("visited", constant(true)).aggregate(header("cheese")).to("mock:result"); - -// in this sample we aggregate using our own strategy with a completion predicate -// stating that the aggregated header is equal to 5. -from("direct:predicate").aggregate(header("cheese"), new MyAggregationStrategy()). - completionPredicate(header("aggregated").isEqualTo(5)).to("mock:result"); - -// this sample is similar to the one above but it also illustrates the use of outBatchSize -// to send exchanges to mock:endpoint in batches of 10. -from("direct:outBatchPredicate").aggregate(header("cheese"), new MyAggregationStrategy()). - completionPredicate(header("aggregated").isEqualTo(5)).outBatchSize(10).to("mock:result"); --------------------------------------------------------- - -If you were using JMS then you may wish to use the JMSDestination header as the correlation key; or some custom header for the stock symbol (using the above stock market example): - -[source,java] --------------------------------------------------------- -from("activemq:someReallyFastTopic").aggregator(header("JMSDestination")).to("activemq:someSlowTopicForGuis"); --------------------------------------------------------- - -You can of course use many different link:../../../../../docs/user-manual/en/expression.adoc[Expression] languages such as XPath, XQuery, SQL or various Scripting Languages. -Here is an example using *XPath*: - -[source,java] --------------------------------------------------------- -//aggregate based on the message content using an XPath expression -//example assumes an XML document starting with <stockQuote symbol='...'> -//aggregate messages based on their symbol attribute within the <stockQuote> element -from("seda:start").aggregate().xpath("/stockQuote/@symbol", String.class).batchSize(5).to("mock:result"); - -//this example will aggregate all messages starting with <stockQuote symbol='APACHE'> into -//one exchange and all the other messages (different symbol or different root element) into another exchange. -from("seda:start").aggregate().xpath("name(/stockQuote[@symbol='APACHE'])", String.class).batchSize(5).to("mock:result"); --------------------------------------------------------- - -For further examples of this pattern in use you could look at the junit test case. - -### Using the Spring XML Extensions - -[NOTE] -==== -The correlationExpression element is in Camel 2.0. For earlier versions of Camel you will need to specify your expression without the enclosing correlationExpression element. - -[source,java] --------------------------------------------------------- -<aggregator> - <simple>header.cheese</simple> - <to uri="mock:result"/> -</aggregator> --------------------------------------------------------- -==== - -The following example shows how to create a simple aggregator using the XML notation; using an link:../../../../../docs/user-manual/en/expression.adoc[Expression] for the correlation value used to aggregate messages together: - -[source,xml] --------------------------------------------------------- -<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> - <route> - <from uri="direct:start"/> - <aggregate> - <correlationExpression> - <simple>header.cheese</simple> - </correlationExpression> - <to uri="mock:result"/> - </aggregate> - </route> - - <route> - <from uri="seda:header"/> - <process ref="setHeaderProcessor"/> - <to uri="direct:temp"/> - </route> - - <route> - <from uri="direct:temp"/> - <aggregate> - <correlationExpression> - <simple>header.cheese</simple> - </correlationExpression> - <to uri="mock:result"/> - </aggregate> - </route> - - <route> - <from uri="direct:predicate"/> - <aggregate strategyRef="myAggregatorStrategy"> - <correlationExpression> - <simple>header.cheese</simple> - </correlationExpression> - <to uri="mock:result"/> - <completionPredicate> - <method bean="myAggregatorStrategy" method="isCompleted"/> - </completionPredicate> - </aggregate> - </route> - - <route> - <from uri="direct:outBatchPredicate"/> - <aggregate strategyRef="myAggregatorStrategy" outBatchSize="10"> - <correlationExpression> - <simple>header.cheese</simple> - </correlationExpression> - <to uri="mock:result"/> - <completionPredicate> - <method bean="myAggregatorStrategy" method="isCompleted"/> - </completionPredicate> - </aggregate> - </route> - - <!-- This route turns off in batching by setting batchSize to 1 to run unit test for out batching. - Normal use cases may not want to disable in batching - --> - <route> - <from uri="direct:outBatchNoInBatching"/> - <aggregate strategyRef="myAggregatorStrategy" batchSize="1" outBatchSize="10"> - <correlationExpression> - <simple>header.cheese</simple> - </correlationExpression> - <to uri="mock:result"/> - <completionPredicate> - <method bean="myAggregatorStrategy" method="isCompleted"/> - </completionPredicate> - </aggregate> - </route> -</camelContext> --------------------------------------------------------- - -You can specify your own AggregationStrategy if you prefer as shown in the following example: -[source,xml] --------------------------------------------------------- -<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> - <route> - <from uri="direct:start"/> - <aggregate strategyRef="aggregatorStrategy"> - <correlationExpression> - <simple>header.cheese</simple> - </correlationExpression> - <to uri="mock:result"/> - </aggregate> - </route> -</camelContext> - -<bean id="aggregatorStrategy" class="org.apache.camel.spring.processor.MyAggregator"/> --------------------------------------------------------- - -Notice how the `strategyRef` attribute is used on the `<aggregator>` element to refer to the custom strategy in Spring. - -### Exchange Properties -The following properties is set on each Exchange that are aggregated: - -[width="100%",cols="3,1,6",options="header"] -|======================================================================= -| Header | Type | Description -| `org.apache.camel.Exchange.AggregatedCount` | int | Camel 1.x: The total number of Exchanges aggregated in this combined Exchange. -| `CamelAggregatedSize` | int | Camel 2.0: The total number of Exchanges aggregated into this combined Exchange. -| `CamelAggregatedIndex` | int | Camel 2.0: The current index of this Exchange in the batch. -|======================================================================= - - -[width="100%",cols="3,1,6",options="header"] -|======================================================================= -| Option | Default | Description -| batchSize | 100 | The `in` batch size. This is the number of incoming exchanges that is processed by the aggregator and when this threshold is reached the batch is completed and send. *Camel 1.6.2/2.0*: You can disable the batch size so the Aggregator is only triggered by timeout by setting the `batchSize` to 0 (or negative). In *Camel 1.6.1* or older you can set the `batchSize` to a very large number to archive the same. -| outBatchSize | 0 | *Camel 1.5*: The `out` batch size. This is the number of exchanges currently aggregated in the `AggregationCollection`. When this threshold is reached the batch is completed and send. By default this option is disabled. The difference to the `batchSize` options is that this is for outgoing, so setting this size to e.g. 50 ensures that this batch will at maximum contain 50 exchanges when its sent. -| batchTimeout | 1000L | Timeout in millis. How long should the aggregator wait before its completed and sends whatever it has currently aggregated. -| groupExchanges | false | *Camel 2.0*: If enabled then Camel will group all aggregated Exchanges into a single combined `org.apache.camel.impl.GroupedExchange` holder class that holds all the aggregated Exchanges. And as a result only one Exchange is being sent out from the aggregator. Can be used to combine many incoming Exchanges into a single output Exchange without coding a custom AggregationStrategy yourself. -| batchConsumer | false | *Camel 2.0*: This option is if the exchanges are coming from a Batch Consumer. Then when enabled the Aggregator will use the batch size determined by the Batch Consumer in the message header `CamelBatchSize`. See more details at Batch Consumer. This can be used to aggregate all files consumed from a File endpoint in that given poll. -| completionPredicate | null | Allows you to use a Predicate to signal when an aggregation is complete. See *warning* in top of this page. -|======================================================================= - -### AggregationCollection and AggregationStrategy -This aggregator uses an AggregationCollection to store the exchanges that are currently aggregated. The AggregationCollection uses a correlation link:../../../../../docs/user-manual/en/expression.adoc[Expression] and an AggregationStrategy: - -* The correlation link:../../../../../docs/user-manual/en/expression.adoc[Expression] is used to correlate the incoming exchanges. The default implementation will group messages based on the correlation expression. Other implementations could for instance just add all exchanges as a batch. -* The strategy is used for aggregate the old (lookup by its correlation id) and the new exchanges together into a single exchange. Possible implementations include performing some kind of combining or delta processing, such as adding line items together into an invoice or just using the newest exchange and removing old exchanges such as for state tracking or market data prices; where old values are of little use. - -Camel provides these implementations: - -* `DefaultAggregationCollection` -* `PredicateAggregationCollection` -* `UseLatestAggregationStrategy` - -### Examples -#### Default example -By default Camel uses `DefaultAggregationCollection` and `UseLatestAggregationStrategy`, so this simple example will just keep the latest received exchange for the given correlation link:../../../../../docs/user-manual/en/expression.adoc[Expression]: - -[source,java] --------------------------------------------------------- -// our route is aggregating from the direct queue and sending the response to the mock -from("direct:start") - // aggregated by header id - // as we have not configured more on the aggregator it will default to aggregate the - // latest exchange only - .aggregate().header("id") - // wait for 0.5 seconds to aggregate - .batchTimeout(500L) - .to("mock:result"); --------------------------------------------------------- - -#### Using PredicateAggregationCollection -The `PredicateAggregationCollection` is an extension to `DefaultAggregationCollection` that uses a Predicate as well to determine the completion. For instance the Predicate can test for a special header value, a number of maximum aggregated so far etc. To use this the routing is a bit more complex as we need to create our `AggregationCollection` object as follows: -[source,java] --------------------------------------------------------- -// create the aggregation collection we will use. -// - we will correlate the received message based on the id header -// - as we will just keep the latest message we use the latest strategy -// - and finally we stop aggregate if we receive 2 or more messages -AggregationCollection ag = new PredicateAggregationCollection(header("id"), - new UseLatestAggregationStrategy(), - property(Exchange.AGGREGATED_SIZE).isEqualTo(3)); - -// our route is aggregating from the direct queue and sending the response to the mock -from("direct:start") - // we use the collection based aggregator we already have configured - .aggregate(ag) - // wait for 0.5 seconds to aggregate - .batchTimeout(500L) - .to("mock:result"); --------------------------------------------------------- - -In this sample we use the predicate that we want at most 3 exchanges aggregated by the same correlation id, this is defined as: -[source,java] --------------------------------------------------------- -header(Exchange.AGGREGATED_COUNT).isEqualTo(3) --------------------------------------------------------- - -Using this the aggregator will complete if we receive 3 exchanges with the same correlation id or when the specified timeout of 500 msecs has elapsed (whichever criteria is met first). - -#### Using custom aggregation strategy -In this example we will aggregate incoming bids and want to aggregate the highest bid. So we provide our own strategy where we implement the code logic: -[source,java] --------------------------------------------------------- -private static class MyAggregationStrategy implements AggregationStrategy { - - public Exchange aggregate(Exchange oldExchange, Exchange newExchange) { - if (oldExchange == null) { - // the first time we only have the new exchange so it wins the first round - return newExchange; - } - int oldPrice = oldExchange.getIn().getBody(Integer.class); - int newPrice = newExchange.getIn().getBody(Integer.class); - // return the "winner" that has the highest price - return newPrice > oldPrice ? newExchange : oldExchange; - } -} --------------------------------------------------------- - -Then we setup the routing as follows: -[source,java] --------------------------------------------------------- -// our route is aggregating from the direct queue and sending the response to the mock -from("direct:start") - // aggregated by header id and use our own strategy how to aggregate - .aggregate(new MyAggregationStrategy()).header("id") - // wait for 0.5 seconds to aggregate - .batchTimeout(500L) - .to("mock:result"); --------------------------------------------------------- - -And since this is based on an unit test we show the test code that send the bids and what is expected as the *winners*: -[source,java] --------------------------------------------------------- -MockEndpoint result = getMockEndpoint("mock:result"); - -// we expect to find the two winners with the highest bid -result.expectedMessageCount(2); -result.expectedBodiesReceived("200", "150"); - -// then we sent all the message at once -template.sendBodyAndHeader("direct:start", "100", "id", "1"); -template.sendBodyAndHeader("direct:start", "150", "id", "2"); -template.sendBodyAndHeader("direct:start", "130", "id", "2"); -template.sendBodyAndHeader("direct:start", "200", "id", "1"); -template.sendBodyAndHeader("direct:start", "190", "id", "1"); - -assertMockEndpointsSatisfied(); --------------------------------------------------------- - -#### Using custom aggregation collection -In this example we will aggregate incoming bids and want to aggregate the bids in reverse order (this is just an example). So we provide our own collection where we implement the code logic: -[source,java] --------------------------------------------------------- -class MyReverseAggregationCollection extends AbstractCollection<Exchange> implements AggregationCollection { - - private List<Exchange> collection = new ArrayList<Exchange>(); - private Expression correlation; - private AggregationStrategy strategy; - - public Expression getCorrelationExpression() { - return correlation; - } - - public void setCorrelationExpression(Expression correlationExpression) { - this.correlation = correlationExpression; - } - - public AggregationStrategy getAggregationStrategy() { - return strategy; - } - - public void setAggregationStrategy(AggregationStrategy aggregationStrategy) { - this.strategy = aggregationStrategy; - } - - public boolean add(Exchange exchange) { - return collection.add(exchange); - } - - public Iterator<Exchange> iterator() { - // demonstrate the we can do something with this collection, so we reverse it - Collections.reverse(collection); - - return collection.iterator(); - } - - public int size() { - return collection.size(); - } - - public void clear() { - collection.clear(); - } - - public void onAggregation(Object correlationKey, Exchange newExchange) { - add(newExchange); - } -} --------------------------------------------------------- - -Then we setup the routing as follows: -[source,java] --------------------------------------------------------- -// our route is aggregating from the direct queue and sending the response to the mock -from("direct:start") - // use our own collection for aggregation - .aggregate(new MyReverseAggregationCollection()) - // wait for 0.5 seconds to aggregate - .batchTimeout(500L) - .to("mock:result"); -And since this is based on an unit test we show the test code that send the bids and what is expected as the expected reverse order: -MockEndpoint result = getMockEndpoint("mock:result"); - -// we expect 5 messages since our custom aggregation collection just gets it all -// but returns them in reverse order -result.expectedMessageCount(5); -result.expectedBodiesReceived("190", "200", "130", "150", "100"); - -// then we sent all the message at once -template.sendBodyAndHeader("direct:start", "100", "id", "1"); -template.sendBodyAndHeader("direct:start", "150", "id", "2"); -template.sendBodyAndHeader("direct:start", "130", "id", "2"); -template.sendBodyAndHeader("direct:start", "200", "id", "1"); -template.sendBodyAndHeader("direct:start", "190", "id", "1"); - -assertMockEndpointsSatisfied(); --------------------------------------------------------- - -*Custom aggregation collection in Spring DSL* -You can also specify a custom aggregation collection in the Spring DSL. Here is an example for Camel 2.0 -[source,xml] --------------------------------------------------------- -<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> - <route> - <from uri="direct:start"/> - <aggregate batchTimeout="500" collectionRef="aggregatorCollection"> - <to uri="mock:result"/> - </aggregate> - </route> -</camelContext> - -<bean id="aggregatorCollection" class="org.apache.camel.processor.aggregator.MyReverseAggregationCollection"/> --------------------------------------------------------- - -In Camel 1.5.1 you will need to specify the aggregator as -[source,xml] --------------------------------------------------------- -<aggregator batchTimeout="500" collectionRef="aggregatorCollection"> - <expression/> - <to uri="mock:result"/> -</aggregator> --------------------------------------------------------- - - -#### Using Grouped Exchanges -*Available as of Camel 2.0* -You can enable grouped exchanges to combine all aggregated exchanges into a single `org.apache.camel.impl.GroupedExchange` holder class that contains all the individual aggregated exchanges. This allows you to process a single Exchange containing all the aggregated exchange. Lets start with how to configure this in the router: -[source,java] --------------------------------------------------------- -// our route is aggregating from the direct queue and sending the response to the mock -from("direct:start") - // aggregate all using same expression - .aggregate().constant(true) - // wait for 0.5 seconds to aggregate - .batchTimeout(500L) - // group the exchanges so we get one single exchange containing all the others - .groupExchanges() - .to("mock:result"); --------------------------------------------------------- - -And the next part is part of an unit code that demonstrates this feature as we send in 5 exchanges each with a different value in the body. -And we will only get 1 exchange out of the aggregator, but we can access all the individual aggregated exchanges from the List which we can extract as a property from the Exchange using the key `Exchange.GROUPED_EXCHANGE`. -[source,java] --------------------------------------------------------- -MockEndpoint result = getMockEndpoint("mock:result"); - -// we expect 1 messages since we group all we get in using the same correlation key -result.expectedMessageCount(1); - -// then we sent all the message at once -template.sendBody("direct:start", "100"); -template.sendBody("direct:start", "150"); -template.sendBody("direct:start", "130"); -template.sendBody("direct:start", "200"); -template.sendBody("direct:start", "190"); - -assertMockEndpointsSatisfied(); - -Exchange out = result.getExchanges().get(0); -List<Exchange> grouped = out.getProperty(Exchange.GROUPED_EXCHANGE, List.class); - -assertEquals(5, grouped.size()); - -assertEquals("100", grouped.get(0).getIn().getBody(String.class)); -assertEquals("150", grouped.get(1).getIn().getBody(String.class)); -assertEquals("130", grouped.get(2).getIn().getBody(String.class)); -assertEquals("200", grouped.get(3).getIn().getBody(String.class)); -assertEquals("190", grouped.get(4).getIn().getBody(String.class)); --------------------------------------------------------- - -#### Using Batch Consumer -*Available as of Camel 2.0* -The Aggregator can work together with the Batch Consumer to aggregate the total number of messages that the Batch Consumer have reported. This allows you for instance to aggregate all files polled using the File consumer. -For example: -[source,java] --------------------------------------------------------- -from("file://inbox") - .aggregate(xpath("//order/@customerId"), new AggregateCustomerOrderStrategy()).batchConsumer().batchTimeout(60000).to("bean:processOrder"); --------------------------------------------------------- - -When using `batchConsumer` Camel will automatic adjust the batchSize according to reported by the Batch Consumer in this case the file consumer. -So if we poll in 7 files then the aggregator will aggregate all 7 files before it completes. As the timeout is still in play we set it to 60 seconds. - -#### Using This Pattern -If you would like to use this EIP Pattern then please read the Getting Started, you may also find the Architecture useful particularly the description of Endpoint and URIs. Then you could try out some of the Examples first before trying this pattern out. - -### See also - -* The Loan Broker Example which uses an aggregator -* link:http://tmielke.blogspot.com/2009/01/using-camel-aggregator-correctly.html[Blog post by Torsten Mielke] about using the aggregator correctly. http://git-wip-us.apache.org/repos/asf/camel/blob/9f22fab8/camel-core/src/main/docs/eips/bean-eip.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/eips/bean-eip.adoc b/camel-core/src/main/docs/eips/bean-eip.adoc index 9be102e..6090550 100644 --- a/camel-core/src/main/docs/eips/bean-eip.adoc +++ b/camel-core/src/main/docs/eips/bean-eip.adoc @@ -1,9 +1,8 @@ -## Bean EIP -### Message Filter +== Bean EIP -The *bean:* component binds beans to Camel message exchanges. +The *bean:* EIP binds beans to Camel message exchanges. -### URI Format +=== URI Format [source,java] --------------------- @@ -13,7 +12,7 @@ bean:beanID[?options] Where *beanID* can be any string which is used to look up the bean in the link:registry.html[Registry] -### EIP options +=== EIP options // eip options: START The Bean EIP supports 5 options which are listed below: @@ -30,7 +29,7 @@ The Bean EIP supports 5 options which are listed below: |======================================================================= // eip options: END -### Bean as endpoint +=== Bean as endpoint Camel also supports invoking link:bean.html[Bean] as an Endpoint. In the route below: @@ -43,7 +42,7 @@ Camel will use link:bean-binding.html[Bean Binding] to invoke the `sayHello` method, by converting the Exchange's In body to the `String` type and storing the output of the method on the Exchange Out body. -### Java DSL bean syntax +=== Java DSL bean syntax Java DSL comes with syntactic sugar for the link:bean.html[Bean] component. Instead of specifying the bean explicitly as the endpoint @@ -75,7 +74,7 @@ from("direct:start").bean(new ExampleBean(), "methodName"); from("direct:start").bean(ExampleBean.class); --------------------------------------------------------------- -### Bean binding +=== Bean binding How bean methods to be invoked are chosen (if they are not specified explicitly through the *method* parameter) and how parameter values are @@ -84,7 +83,7 @@ link:bean-binding.html[Bean Binding] mechanism which is used throughout all of the various link:bean-integration.html[Bean Integration] mechanisms in Camel. -### See also +=== See also * link:configuring-camel.html[Configuring Camel] * link:component.html[Component] http://git-wip-us.apache.org/repos/asf/camel/blob/9f22fab8/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 index dd7df33..774595f 100644 --- a/camel-core/src/main/docs/eips/choice-eip.adoc +++ b/camel-core/src/main/docs/eips/choice-eip.adoc @@ -1,4 +1,4 @@ -## Choice EIP +== Choice EIP The http://www.enterpriseintegrationpatterns.com/ContentBasedRouter.html[Content @@ -8,7 +8,7 @@ on the contents of the message exchanges. image:http://www.enterpriseintegrationpatterns.com/img/ContentBasedRouter.gif[image] -### Choice options +=== Choice options // eip options: START The Choice EIP supports 2 options which are listed below: @@ -22,7 +22,7 @@ The Choice EIP supports 2 options which are listed below: |======================================================================= // eip options: END -### Examples +=== 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 @@ -81,7 +81,7 @@ 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 +#=== 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 http://git-wip-us.apache.org/repos/asf/camel/blob/9f22fab8/camel-core/src/main/docs/eips/circuitBreaker-eip.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/eips/circuitBreaker-eip.adoc b/camel-core/src/main/docs/eips/circuitBreaker-eip.adoc index 0231ead..e257bae 100644 --- a/camel-core/src/main/docs/eips/circuitBreaker-eip.adoc +++ b/camel-core/src/main/docs/eips/circuitBreaker-eip.adoc @@ -1,4 +1,4 @@ -## Circuit Breaker EIP (deprecated) +== Circuit Breaker EIP (deprecated) The Circuit Breaker load balancer is a stateful pattern that monitors all calls for certain exceptions. Initially the Circuit Breaker is in closed state and passes all messages. If there are failures and the threshold is reached, it moves to open state and rejects all calls until halfOpenAfter timeout is reached. After this timeout is reached, if there is a new call, it will pass and if the result is success the Circuit Breaker will move to closed state, or to open state if there was an error. When the circuit breaker is closed, it will throw a `java.util.concurrent.RejectedExecutionException`. This can then be caught to provide an alternate path for processing exchanges. @@ -51,6 +51,6 @@ And the same example using Spring XML: </camelContext> -------------------------------------------------------- -### Using This Pattern +=== Using This Pattern If you would like to use this EIP Pattern then please read the Getting Started, you may also find the Architecture useful particularly the description of Endpoint and URIs. Then you could try out some of the Examples first before trying this pattern out. \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/9f22fab8/camel-core/src/main/docs/eips/customLoadBalancer-eip.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/eips/customLoadBalancer-eip.adoc b/camel-core/src/main/docs/eips/customLoadBalancer-eip.adoc index bae84ad..26a0d0c 100644 --- a/camel-core/src/main/docs/eips/customLoadBalancer-eip.adoc +++ b/camel-core/src/main/docs/eips/customLoadBalancer-eip.adoc @@ -1,4 +1,4 @@ -## Custom Load Balancer EIP +== Custom Load Balancer EIP You can use a custom load balancer (eg your own implementation) also.