[camel] 02/02: CAMEL-16861: Cleanup and update EIP docs
This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git commit 8baecff964ce4b8430cdebfab85f729e8e8db4cb Author: Claus Ibsen AuthorDate: Mon Oct 18 14:45:22 2021 +0200 CAMEL-16861: Cleanup and update EIP docs --- .../docs/modules/eips/pages/setOutHeader-eip.adoc | 48 -- 1 file changed, 48 deletions(-) diff --git a/core/camel-core-engine/src/main/docs/modules/eips/pages/setOutHeader-eip.adoc b/core/camel-core-engine/src/main/docs/modules/eips/pages/setOutHeader-eip.adoc deleted file mode 100644 index c9200b9..000 --- a/core/camel-core-engine/src/main/docs/modules/eips/pages/setOutHeader-eip.adoc +++ /dev/null @@ -1,48 +0,0 @@ -= Set Out Header EIP (deprecated) -== Set Header EIP - -This EIP is deprecated. -The SetOutHeader EIP allows you to set an header on the out message of your exchange. - -== Options - -// eip options: START -The Set Out Header EIP supports 1 options which are listed below: - -[width="100%",cols="2,5,^1,2",options="header"] -|=== -| Name | Description | Default | Type -| *headerName* | *Required* Name of message header to set a new value | | String -|=== -// eip options: END - -== Examples - -The following example shows how to use the SetOutHeader EIP - -[source,java] - -RouteBuilder builder = new RouteBuilder() { -public void configure() { -from("direct:a") -.setOutHeader("myHeader", constant("test")) -.to("direct:b"); -} -}; - - - -And the same example using XML: - -[source,xml] - -http://camel.apache.org/schema/spring;> - - - -test - - - - - \ No newline at end of file
[camel] 02/02: CAMEL-16861: Cleanup and update EIP docs
This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git commit bff73f5118aa9ca759646544b546307355021513 Author: Claus Ibsen AuthorDate: Fri Oct 15 10:30:27 2021 +0200 CAMEL-16861: Cleanup and update EIP docs --- .../src/main/docs/modules/eips/pages/sort-eip.adoc | 44 ++ .../docs/modules/eips/pages/transform-eip.adoc | 4 ++ 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/core/camel-core-engine/src/main/docs/modules/eips/pages/sort-eip.adoc b/core/camel-core-engine/src/main/docs/modules/eips/pages/sort-eip.adoc index 426ac17..0fd8330 100644 --- a/core/camel-core-engine/src/main/docs/modules/eips/pages/sort-eip.adoc +++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/sort-eip.adoc @@ -5,9 +5,11 @@ :since: :supportlevel: Stable -Sort can be used to sort a message. Imagine you consume text files and before processing each file you want to be sure the content is sorted. +How you can sort the content of the message? -Sort will by default sort the body using a default comparator that handles numeric values or uses the string representation. You can provide your own comparator, and even an expression to return the value to be sorted. Sort requires the value returned from the expression evaluation is convertible to `java.util.List` as this is required by the JDK sort operation. +image::eip/MessageTranslator.gif[image] + +Use a special filter, a xref:message-translator.adoc[Message Translator], between other filters to sort the content of the message. == Options @@ -15,14 +17,25 @@ Sort will by default sort the body using a default comparator that handles numer include::partial$eip-options.adoc[] // eip options: END +== How sorting works + +Sort will by default sort the message body using a default `Comparator` that handles numeric values +or uses the `String` representation. + +You can also configure a custom `Comparator` to control the sorting. + +An xref:latest@manual:ROOT:expression.adoc[Expression] can also be used, which performs the sorting, and return the sorted message body. +The value returned from the `Expression` must be convertible to `java.util.List` as this is required by the JDK sort operation. -== Samples +=== Using Sort EIP + +Imagine you consume text files and before processing each file you want to be sure the content is sorted. In the route below it will read the file content and tokenize by line breaks so each line can be sorted. [source,java] -from("file://inbox") +from("file:inbox") .sort(body().tokenize("\n")) .to("bean:MyServiceBean.processLine"); @@ -31,37 +44,38 @@ You can pass in your own comparator as a 2nd argument: [source,java] -from("file://inbox") +from("file:inbox") .sort(body().tokenize("\n"), new MyReverseComparator()) .to("bean:MyServiceBean.processLine"); In the route below it will read the file content and tokenize by line breaks so each line can be sorted. +In XML you use the xref:components:languages:tokenize-language.adoc[Tokenize] language as shown: [source,xml] - + -body +\n - + -And to use our own comparator we can refer to it as a spring bean: +And to use our own `Comparator` we do as follows: [source,xml] - - -body + + +${body} - - -Besides ``, you can supply an expression using any language you like, so long as it returns a list. +Notice how we use `$\{body}` in the example above to tell Sort EIP that it should use the message body for sorting. +This is needed when you use a custom `Comparator`. + diff --git a/core/camel-core-engine/src/main/docs/modules/eips/pages/transform-eip.adoc b/core/camel-core-engine/src/main/docs/modules/eips/pages/transform-eip.adoc index c3e4eb1..2cc478f 100644 --- a/core/camel-core-engine/src/main/docs/modules/eips/pages/transform-eip.adoc +++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/transform-eip.adoc @@ -10,8 +10,12 @@ http://www.enterpriseintegrationpatterns.com/MessageTranslator.html[Message Translator] from the xref:enterprise-integration-patterns.adoc[EIP patterns]. +How can systems using different data formats communicate with each other using messaging? + image::eip/MessageTranslator.gif[image] +Use a special filter, a Message Translator, between other filters or applications to translate one data format into another. + The xref:message-translator.adoc[Message Translator] can be done in different ways in Camel: * Using xref:transform-eip.adoc[Transform] or xref:setBody-eip.adoc[Set Body] in the DSL
[camel] 02/02: CAMEL-16861: Cleanup and update EIP docs
This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git commit 1410dea38615fbeb6bc1b88be582cba7c6d370bb Author: Claus Ibsen AuthorDate: Mon Oct 11 14:43:42 2021 +0200 CAMEL-16861: Cleanup and update EIP docs --- .../docs/modules/eips/pages/multicast-eip.adoc | 2 +- .../docs/modules/eips/pages/recipientList-eip.adoc | 334 ++--- .../org/apache/camel/support/ObjectHelper.java | 1 - 3 files changed, 165 insertions(+), 172 deletions(-) diff --git a/core/camel-core-engine/src/main/docs/modules/eips/pages/multicast-eip.adoc b/core/camel-core-engine/src/main/docs/modules/eips/pages/multicast-eip.adoc index fe33060..bc18439 100644 --- a/core/camel-core-engine/src/main/docs/modules/eips/pages/multicast-eip.adoc +++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/multicast-eip.adoc @@ -29,7 +29,7 @@ The following properties are set on each Exchange that are multicasted: |=== | Property | Type | Description | `CamelMulticastIndex` | `int` | An index counter that increases for each Exchange being multicasted. The counter starts from 0. -| `MULTICAST_COMPLETE` | `boolean` |Whether or not this Exchange is the last. +| `CamelMulticastComplete` | `boolean` | Whether this Exchange is the last. |=== == Using Multicast diff --git a/core/camel-core-engine/src/main/docs/modules/eips/pages/recipientList-eip.adoc b/core/camel-core-engine/src/main/docs/modules/eips/pages/recipientList-eip.adoc index 83d2abe..e0c6e13 100644 --- a/core/camel-core-engine/src/main/docs/modules/eips/pages/recipientList-eip.adoc +++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/recipientList-eip.adoc @@ -5,11 +5,15 @@ :since: :supportlevel: Stable -image::eip/RecipientList.gif[image] +Camel supports the +https://www.enterpriseintegrationpatterns.com/RecipientList.html[Recipient List] +from the xref:enterprise-integration-patterns.adoc[EIP patterns]. -The recipients will receive a copy of the *same* Exchange, and Camel will execute them sequentially. +How do we route a message to a list of dynamically specified recipients? -TIP: See the `cacheSize` option for more details on _how much cache_ to use depending on how many or few unique endpoints are used. +image::eip/RecipientList.gif[image] + +Define a channel for each recipient. Then use a Recipient List to inspect an incoming message, determine the list of desired recipients, and forward the message to all channels associated with the recipients in the list. == Options @@ -18,39 +22,63 @@ include::partial$eip-options.adoc[] // eip options: END -[TIP] - -You can use the RecipientList Annotation on a POJO to create a Dynamic Recipient List. For more details see the Bean Integration. - +TIP: See the `cacheSize` option for more details on _how much cache_ to use depending on how many or few unique endpoints are used. + +== Exchange properties -== Static Recipient List -The following example shows how to route a request from an input *queue:a* endpoint to a static list of destinations +The following properties are set on each Exchange that are sent by the recipient list: + +[width="100%",cols="3,1m,6",options="header"] +|=== +| Property | Type | Description +| `CamelRecipientListEndpoint` | `String` | Uri of the `Endpoint` that the message was sent to. +|=== + +== Using Recipient List + +The Recipient List EIP allows to route *the same* message to a number of xref:latest@manual:ROOT:endpoint.adoc[endpoints] +and process them in a different way. + +There can be 1 or more destinations, and Camel will execute them sequentially (by default). +However, a parallel mode exists which allows processing messages concurrently. + +The Recipient List EIP has many features and is based on the xref:multicast-eip.adoc[Multicast] EIP. +For example the Recipient List EIP is capable of aggregating each message into a single +_response_ message as the result after the Recipient List EIP. + +=== Using static Recipient List + +The following example shows how to route a request from an input queue:a endpoint +to a static list of destinations, using `constant`: [source,java] from("jms:queue:a") -.recipientList(constant("direct:b,direct:c,direct:d")); +.recipientList(constant("seda:x,seda:y,seda:z")); And in XML: [source,xml] -http://camel.apache.org/schema/spring;> - - - -direct:b,direct:c,direct:d - - - + + + +seda:x,seda:y,seda:z + + -== Dynamic Recipient List +=== Using dynamic Recipient List + Usually one of the main
[camel] 02/02: CAMEL-16861: Cleanup and update EIP docs
This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git commit 0231a1cecb933ae0a6781b732f43d13e39ef22c4 Author: Claus Ibsen AuthorDate: Mon Oct 11 14:00:53 2021 +0200 CAMEL-16861: Cleanup and update EIP docs --- .../modules/eips/pages/customLoadBalancer-eip.adoc | 17 ++- .../main/docs/modules/eips/pages/sticky-eip.adoc | 21 - .../main/docs/modules/eips/pages/topic-eip.adoc| 17 +++ .../main/docs/modules/eips/pages/weighted-eip.adoc | 34 +- 4 files changed, 56 insertions(+), 33 deletions(-) diff --git a/core/camel-core-engine/src/main/docs/modules/eips/pages/customLoadBalancer-eip.adoc b/core/camel-core-engine/src/main/docs/modules/eips/pages/customLoadBalancer-eip.adoc index 89d5dd5..33b1935 100644 --- a/core/camel-core-engine/src/main/docs/modules/eips/pages/customLoadBalancer-eip.adoc +++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/customLoadBalancer-eip.adoc @@ -20,7 +20,10 @@ An example using Java DSL: from("direct:start") // using our custom load balancer .loadBalance(new MyLoadBalancer()) -.to("mock:x", "mock:y", "mock:z"); +.to("seda:x") +.to("seda:y") +.to("seda:z") +.end(); And the same example using XML DSL: @@ -28,18 +31,18 @@ And the same example using XML DSL: [source,xml] - + http://camel.apache.org/schema/spring;> - - - - - + + + + + diff --git a/core/camel-core-engine/src/main/docs/modules/eips/pages/sticky-eip.adoc b/core/camel-core-engine/src/main/docs/modules/eips/pages/sticky-eip.adoc index d64bfda..7f733ed 100644 --- a/core/camel-core-engine/src/main/docs/modules/eips/pages/sticky-eip.adoc +++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/sticky-eip.adoc @@ -5,7 +5,10 @@ :since: :supportlevel: Stable -Sticky Load Balancer. Sticky load balancing uses an Expression to calculate a correlation key to perform the sticky load balancing. +Sticky mode for the xref:loadBalance-eip.adoc[Load Balancer] EIP. + +A stick mode means that a correlation key (calculated as xref:latest@manual:ROOT:expression.adoc[Expression]) +is used to determine the destination. This allows to route all messages with the same key to the same destination. == Options @@ -15,29 +18,33 @@ include::partial$eip-options.adoc[] == Examples -In this case we are using the header test as correlation expression: +In this case we are using the header myKey as correlation expression: [source,java] from("direct:start") -.loadBalance() -.sticky(header("test")) -.to("seda:x", "seda:y", "seda:z"); +.loadBalance().sticky(header("myKey")) +.to("seda:x") +.to("seda:y") +.to("seda:z") +.end(); -In XML you'll have a route like this +In XML you'll have a route like this: [source,xml] + - test + myKey + diff --git a/core/camel-core-engine/src/main/docs/modules/eips/pages/topic-eip.adoc b/core/camel-core-engine/src/main/docs/modules/eips/pages/topic-eip.adoc index a4898f8..1d40bff 100644 --- a/core/camel-core-engine/src/main/docs/modules/eips/pages/topic-eip.adoc +++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/topic-eip.adoc @@ -5,7 +5,8 @@ :since: :supportlevel: Stable -Topic Load Balancer, with this policy you'll get a Topic behavior by sending to all destinations. +Topic mode for the xref:loadBalance-eip.adoc[Load Balancer] EIP. +With this policy then all destination is selected. == Options @@ -15,20 +16,23 @@ include::partial$eip-options.adoc[] == Examples -In this case we are using the header test as correlation expression: +In this example we send the message to all three endpoints: [source,java] from("direct:start") -.loadBalance() -.topic() -.to("seda:x", "seda:y", "seda:z"); +.loadBalance().topic() +.to("seda:x") +.to("seda:y") +.to("seda:z") +.end(); -In XML you'll have a route like this +In XML you'll have a route like this: [source,xml] + @@ -36,4 +40,5 @@ In XML you'll have a route like this + diff --git a/core/camel-core-engine/src/main/docs/modules/eips/pages/weighted-eip.adoc b/core/camel-core-engine/src/main/docs/modules/eips/pages/weighted-eip.adoc index d4c2d17..df7c433 100644 --- a/core/camel-core-engine/src/main/docs/modules/eips/pages/weighted-eip.adoc +++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/weighted-eip.adoc @@ -5,7 +5,8 @@ :since: :supportlevel: Stable -Weighted Load Balancer, with this policy in case of failures the exchange will be tried
[camel] 02/02: CAMEL-16861: Cleanup and update EIP docs
This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git commit 2e2c1bb720a89425cd235c345c5b601682ad345a Author: Claus Ibsen AuthorDate: Thu Oct 7 14:35:47 2021 +0200 CAMEL-16861: Cleanup and update EIP docs --- .../modules/eips/pages/message-translator.adoc | 88 +- 1 file changed, 53 insertions(+), 35 deletions(-) diff --git a/core/camel-core-engine/src/main/docs/modules/eips/pages/message-translator.adoc b/core/camel-core-engine/src/main/docs/modules/eips/pages/message-translator.adoc index bc6b08a..aaf8ad2 100644 --- a/core/camel-core-engine/src/main/docs/modules/eips/pages/message-translator.adoc +++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/message-translator.adoc @@ -12,70 +12,88 @@ The Message Translator can be done in different ways in Camel: * Using xref:transform-eip.adoc[Transform] in the DSL * Calling a xref:latest@manual:ROOT:processor.adoc[Processor] or xref:latest@manual:ROOT:bean-integration.adoc[bean] to perform the transformation +* Using template-based xref:components::index.adoc[Components], with the template being the source for how the message is translated * Messages can also be transformed using xref:latest@manual:ROOT:data-format.adoc[Data Format] to marshal and unmarshal messages in different encodings. == Example -You can transform a message using Camel's -xref:latest@manual:ROOT:bean-integration.adoc[Bean Integration] to call any method on a -bean in your xref:latest@manual:ROOT:registry.adoc[Registry] such as your -xref:latest@manual:ROOT:spring.adoc[Spring] XML configuration file as follows +Each of above approaches is documented in the following examples + +=== Message Translator with Bean + +You can transform a message using Camels +xref:latest@manual:ROOT:bean-integration.adoc[Bean Integration] to call any method on a bean +that performs the message translation: [source,java] -from("activemq:SomeQueue") - .bean("myTransformerBean", "myMethodName") - .to("mqseries:AnotherQueue"); +from("activemq:cheese") + .bean("myTransformerBean", "doTransform") + .to("activemq:wine"); -Where the "myTransformerBean" would be defined in a Spring XML file or -defined in JNDI etc. You can omit the method name parameter from -beanRef() and the xref:latest@manual:ROOT:bean-integration.adoc[Bean Integration] will try -to deduce the method to invoke from the message exchange. +And in XML: + +[source,xml] + + + + + + + -or you can add your own explicit xref:latest@manual:ROOT:processor.adoc[Processor] to do -the transformation +=== Message Translator with Processor -or you can use the DSL to explicitly configure the transformation +You can also use a xref:latest@manual:ROOT:processor.adoc[Processor] to do +the transformation: -You can also use xref:latest@manual:ROOT:spring-xml-extensions.adoc[Spring XML Extensions] -to do a transformation. Basically any xref:latest@manual:ROOT:expression.adoc[Expression] -language can be substituted inside the transform element as shown below +[source,java] + +from("activemq:cheese") + .process(new MyTransformerProcessor()) + .to("activemq:wine"); + -Or you can use the xref:latest@manual:ROOT:bean-integration.adoc[Bean Integration] to -invoke a bean +And in XML: [source,xml] - - - + + + -You can also consume a message -from one destination, transform it with something like +=== Message Translator using Templating Components + +You can also consume a message from one destination, transform it with something like xref:components::velocity-component.adoc[Velocity] or xref:components::xquery-component.adoc[XQuery] and then send -it on to another destination. For example using InOnly (one way -messaging) +it on to another destination. [source,java] -from("activemq:My.Queue") +from("activemq:cheese") .to("velocity:com/acme/MyResponse.vm") -.to("activemq:Another.Queue"); +.to("activemq:wine"); -If you want to use InOut (request-reply) semantics to process requests -on the *My.Queue* queue on xref:components::activemq-component.adoc[ActiveMQ] with a template -generated response, then sending responses back to the JMSReplyTo -Destination you could use this. +And in XML: -[source,java] +[source,xml] -from("activemq:My.Queue") -.to("velocity:com/acme/MyResponse.vm"); + + + + + +=== Message Translator using Data Format + +TODO: + + +
[camel] 02/02: CAMEL-16861: Cleanup and update EIP docs
This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git commit 7d440e8411771448e9fd1d7cb8db705029b90c8d Author: Claus Ibsen AuthorDate: Thu Sep 23 15:49:43 2021 +0200 CAMEL-16861: Cleanup and update EIP docs --- .../main/docs/modules/eips/pages/intercept.adoc| 304 ++--- .../model/InterceptSendToEndpointDefinition.java | 12 + 2 files changed, 215 insertions(+), 101 deletions(-) diff --git a/core/camel-core-engine/src/main/docs/modules/eips/pages/intercept.adoc b/core/camel-core-engine/src/main/docs/modules/eips/pages/intercept.adoc index 1408637..0cf663b 100644 --- a/core/camel-core-engine/src/main/docs/modules/eips/pages/intercept.adoc +++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/intercept.adoc @@ -3,7 +3,7 @@ The intercept feature in Camel supports intercepting xref:latest@manual:ROOT:exchange.adoc[Exchange]'s' while they are being routed. -== Interceptor kinds +== Kinds of interceptors Camel supports three kinds of interceptors: @@ -12,6 +12,49 @@ Camel supports three kinds of interceptors: * `interceptSendToEndpoint` that intercepts only when an xref:latest@manual:ROOT:exchange.adoc[Exchange] is about to be sent to the given xref:message-endpoint.adoc[endpoint]. +The `interceptSendToEndpoint` is dynamic hence it will also trigger if a +dynamic URI is constructed that Camel was not aware of at startup +time. + +The `interceptFrom` is not dynamic, and will only intercept +all the known routes when Camel is starting. +So if you construct a `Consumer` using the Camel Java API and consumes +messages from this endpoint, then the `interceptFrom` is not triggered. + +=== Interceptor scopes + +All the interceptors can be configured on global, route scope, or with +xref:latest@manual:ROOT:route-configuration.adoc[Route Configuration]. + +This means multiple interceptors can be _triggered_. + +Most of the examples in this page are on global scope. +To use route scope, then its similar but is done on the route. + +For example the first example further below can be done as shown on route scope: + +[source,java] +- +from("jms:queue:order") + .intercept().to("log:hello").end() // intercepts only in this route + .to("bean:validateOrder") + .to("bean:processOrder"); +- + +And in XML: + +[source,xml] + + + + + + + + + + + === Common features of the interceptors All these interceptors support the following features: @@ -19,7 +62,7 @@ All these interceptors support the following features: * xref:latest@manual:ROOT:predicate.adoc[Predicate] using `when` to only trigger the interceptor in certain conditions * `stop` forces stopping continue routing the Exchange and mark it as completed successful (it's actually the xref:stop-eip.adoc[Stop] EIP). * `skip` when used with `interceptSendToEndpoint` will *skip* sending the message to the original intended endpoint. -* `afterUrl` when used with `interceptSendToEndpoint` allows to send +* `afterUri` when used with `interceptSendToEndpoint` allows to send the message to an xref:message-endpoint.adoc[endpoint] afterwards. * `interceptFrom` and `interceptSendToEndpoint` supports endpoint URI pattern matching by: exact uri, wildcard, regular expression. See further below for more details. @@ -235,139 +278,211 @@ And in XML: - == Using intercept when sending to an endpoint -TODO: Continue HERE +You can also intercept when Camel is sending a message to an xref:message-endpoint.adoc[endpoint]. +This can be used to do some custom processing before the +message is sent to the intended destination. -Intercept send to endpoint is triggered when an -Exchange is being sent to the intercepted endpoint. -This allows you to route the Exchange to a -detour or do some custom processing before the -Exchange is sent to the original intended -destination. You can also skip sending to the intended destination. By -default Camel will send to the original intended destination after the -intercepted route completes. And as the regular intercept you can also -define an `when` Predicate so we only intercept if -the Predicate evaluates to *true*. This allows you -do a bit of filtering, to only intercept when certain criteria is -meet. And finally you can send the Exchange to an endpoint with the `afterUrl` option. You can use this to process the response from the original endpoint. +The interceptor can also be configured to not send to the destination (skip) +which means the message is detoured instead. -Let start with a simple example, where we want to intercept when an -Exchange is being sent to `mock:foo`: +A xref:latest@manual:ROOT:predicate.adoc[Predicate] can also be used +to control when to intercept,