From ca25f415cf27e471283c296754e12414fc5daf2d Mon Sep 17 00:00:00 2001 From: Sezgin Date: Thu, 8 Mar 2018 10:23:35 +0300 Subject: [PATCH] CAMEL-11497 - add missing to-eip.adoc toD-eip.adoc transform-eip.adoc process-eip.adoc --- .../src/main/docs/eips/message-endpoint.adoc | 141 +----------------- camel-core/src/main/docs/eips/message.adoc | 43 +----- .../src/main/docs/eips/process-eip.adoc | 106 +++++++++++++ camel-core/src/main/docs/eips/to-eip.adoc | 91 +++++++++++ camel-core/src/main/docs/eips/toD-eip.adoc | 117 +++++++++++++++ .../src/main/docs/eips/transform-eip.adoc | 12 ++ 6 files changed, 329 insertions(+), 181 deletions(-) create mode 100644 camel-core/src/main/docs/eips/process-eip.adoc create mode 100644 camel-core/src/main/docs/eips/to-eip.adoc create mode 100644 camel-core/src/main/docs/eips/toD-eip.adoc create mode 100644 camel-core/src/main/docs/eips/transform-eip.adoc diff --git a/camel-core/src/main/docs/eips/message-endpoint.adoc b/camel-core/src/main/docs/eips/message-endpoint.adoc index 3c37ff855d1af..17bc4eda09bfa 100644 --- a/camel-core/src/main/docs/eips/message-endpoint.adoc +++ b/camel-core/src/main/docs/eips/message-endpoint.adoc @@ -24,150 +24,13 @@ implementations. [[MessageEndpoint-Example]] === Samples -The following example route demonstrates the use of a file consumer endpoint and a JMS producer endpoint. - -[source,java] ----- -from("file://local/router/messages/foo") - .to("jms:queue:foo"); ----- - -And in XML: - -[source,xml] ----- - - - - ----- - - -[[MessageEndpoint-DynamicTo]] -=== Dynamic To - -*Available as of Camel 2.16* - -There is a new `.toD` / `` that allows to send a message to a dynamic -computed link:endpoint.html[Endpoint] using one or -more link:expression.html[Expression] that are concat together. By -default the <> language is used to compute -the endpoint. For example to send a message to a endpoint defined by a -header you can do as shown below: - -[source,java] ----- -from("direct:start") - .toD("${header.foo}"); ----- - -And in XML: - -[source,xml] ----- - - - - ----- - -You can also prefix the uri with a value because by default the uri is -evaluated using the <> language - -[source,java] ----- -from("direct:start") - .toD("mock:${header.foo}"); ----- - -And in XML: - -[source,xml] ----- - - - - ----- - -In the example above we compute an endpoint that has prefix "mock:" and -then the header foo is appended. So for example if the header foo has -value order, then the endpoint is computed as "mock:order". - -You can also use other languages than <> such -as <> - this requires to prefix with language: as -shown below (simple language is the default language). If you do not -specify language: then the endpoint is a component name. And in some -cases there is both a component and language with the same name such as -xquery. - -[source,xml] ----- - - - - ----- - -This is done by specifying the name of the language followed by a colon. - -[source,java] ----- -from("direct:start") - .toD("language:xpath:/order/@uri"); ----- - -You can also concat multiple <>(s) together -using the plus sign `+` such as shown below: - -[source,xml] ----- - - - - ----- - -In the example above the uri is a combination -of <> language and <> where -the first part is simple (simple is default language). And then the plus -sign separate to another language, where we specify the language name -followed by a colon - -[source,java] ----- -from("direct:start") - .toD("jms:${header.base}+language:xpath:/order/@id"); ----- - -You can concat as many languages as you want, just separate them with -the plus sign - -The Dynamic To has a few options you can configure - -[width="100%",cols="10%,10%,80%",options="header",] -|=== -|Name |Default Value |Description - -| *uri* | | *Mandatory:* The uri to use. See above - -| *pattern* | | To set a specific link:exchange-pattern.html[Exchange Pattern] to use -when sending to the endpoint. The original MEP is restored afterwards. - -| *cacheSize* | 1000 | Allows to configure the cache size for the `ProducerCache` which caches -producers for reuse. Will by default use the default cache size which is -1000. Setting the value to -1 allows to turn off the cache all together. - -| *ignoreInvalidEndpoint* | false | Whether to ignore an endpoint URI that could not be resolved. If -disabled, Camel will throw an exception identifying the invalid endpoint -URI. -|=== - +See first example in link:https://github.com/apache/camel/blob/master/camel-core/src/main/docs/eips/to-eip.adoc[To EIP] === See Also For more details see: +* link:https://github.com/apache/camel/blob/master/camel-core/src/main/docs/eips/toD-eip.adoc[ToD EIP] * link:recipient-list.html[Recipient List] * link:message.html[Message] * link:wire-tap.html[Wire Tap] diff --git a/camel-core/src/main/docs/eips/message.adoc b/camel-core/src/main/docs/eips/message.adoc index 15c21e14fc5e5..1c89282f33ffd 100644 --- a/camel-core/src/main/docs/eips/message.adoc +++ b/camel-core/src/main/docs/eips/message.adoc @@ -41,45 +41,4 @@ from("direct:startInOut") .inOut("bean:process"); ---- -Instead of using `inOnly` and `inOut` you may want to keep using `to` -where you can specify the exchange pattern as shown: - -[source,java] ----- -from("direct:startInOnly") - .to(ExchangePattern.InOnly, "bean:process"); - -from("direct:startInOut") - .to(ExchangePattern.InOut, "bean:process"); ----- - - -And here is how to do it in XML: - -[source,xml] ----- - - - - - - - - - ----- - -And here we use `` with the `pattern` attribute to set the exchange pattern: - -[source,xml] ----- - - - - - - - - - ----- +See link:https://github.com/apache/camel/blob/master/camel-core/src/main/docs/eips/to-eip.adoc[to-eip with pattern] diff --git a/camel-core/src/main/docs/eips/process-eip.adoc b/camel-core/src/main/docs/eips/process-eip.adoc new file mode 100644 index 0000000000000..3dc8d23900a07 --- /dev/null +++ b/camel-core/src/main/docs/eips/process-eip.adoc @@ -0,0 +1,106 @@ +[[process-eip]] +== Process EIP + +The http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Processor.html[Processor] interface is used to implement consumers of message exchanges or to implement a link:https://github.com/apache/camel/blob/master/camel-core/src/main/docs/eips/message-translator.adoc[Message Translator] + +=== Options + +// eip options: START +The Process EIP supports 1 options which are listed below: + + +[width="100%",cols="2,5,^1,2",options="header"] +|=== +| Name | Description | Default | Type +| *ref* | *Required* Reference to the Processor to lookup in the registry to use. | | String +|=== +// eip options: END + +=== Samples +===Using a processor in a route + +Once you have written a class which implements processor like this... + +[source,java] +---- +public class MyProcessor implements Processor { + public void process(Exchange exchange) throws Exception { + // do something... + } +} +---- + +You can then easily use this inside a route by declaring the bean in +Spring, say via the XML (or registering it in JNDI if that is your +link:https://github.com/apache/camel/blob/master/docs/user-manual/en/registry.adoc[Registry]) + +[source,xml] +-------------------------------------------------------- + +-------------------------------------------------------- + +Then in Camel you can do + +[source,java] +---- +from("activemq:myQueue").to("myProcessor"); +---- + +==== Using the process DSL + +In your route you can also use the `process` DSL syntax for invoking a +processor. + +[source,java] +---- +Processor myProcessor = new MyProcessor(); +... +from("activemq:myQueue").process(myProcessor); +---- + +If you need to lookup the processor in the link:https://github.com/apache/camel/blob/master/docs/user-manual/en/registry.adoc[Registry] +then you should use the *processRef* DSL: + +[source,java] +---- +from("activemq:myQueue").processRef("myProcessor"); +---- + +=== Why use process when you can use to instead? + +The process can be used in routes as an anonymous inner class such: + +[source,java] +---- + from("activemq:myQueue").process(new Processor() { + public void process(Exchange exchange) throws Exception { + String payload = exchange.getIn().getBody(String.class); + // do something with the payload and/or exchange here + exchange.getIn().setBody("Changed body"); + } + }).to("activemq:myOtherQueue"); +---- + +This is usable for quickly whirling up some code. If the code in the +inner class gets a bit more complicated it is of course advised to +refactor it into a separate class. + +=== Turning your processor into a full Component + +There is a base class called +http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/impl/ProcessorEndpoint.html[ProcessorEndpoint] +which supports the full link:endpoint.html[Endpoint] semantics given a +Processor instance. + +So you just need to create a link:https://github.com/apache/camel/tree/master/components[Component] class by +deriving from +http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/impl/DefaultComponent.html[DefaultComponent] +which returns instances of ProcessorEndpoint. For more details see +link:writing-components.html[Writing Components] + +=== See Also + +* link:https://github.com/apache/camel/blob/master/camel-core/src/main/docs/eips/message-translator.adoc[Message Translator] +* link:https://github.com/apache/camel/blob/master/camel-core/src/main/docs/eips/enrich-eip.adoc[Content Enricher-Enrich EIP] +* link:https://github.com/apache/camel/blob/master/camel-core/src/main/docs/eips/pollEnrich-eip.adoc[Content Enricher-Poll Enrich EIP] +* link:https://github.com/apache/camel/blob/master/camel-core/src/main/docs/eips/content-filter.adoc[Content Filter] \ No newline at end of file diff --git a/camel-core/src/main/docs/eips/to-eip.adoc b/camel-core/src/main/docs/eips/to-eip.adoc new file mode 100644 index 0000000000000..464f0995b24b6 --- /dev/null +++ b/camel-core/src/main/docs/eips/to-eip.adoc @@ -0,0 +1,91 @@ +[[to-eip]] +== To EIP + +See message related documentation + +* link:https://github.com/apache/camel/blob/master/camel-core/src/main/docs/eips/message.adoc[Message] +* link:https://github.com/apache/camel/blob/master/camel-core/src/main/docs/eips/message-bus.adoc[Message Bus] +* link:https://github.com/apache/camel/blob/master/camel-core/src/main/docs/eips/message-channel.adoc[Message Channel] +* link:https://github.com/apache/camel/blob/master/camel-core/src/main/docs/eips/message-endpoint.adoc[Message Endpoint] +* link:https://github.com/apache/camel/blob/master/camel-core/src/main/docs/eips/message-router.adoc[Message Router] +* link:https://github.com/apache/camel/blob/master/camel-core/src/main/docs/eips/message-translator.adoc[Message Translator] + +=== Options + +// eip options: START +The To EIP supports 3 options which are listed below: + + +[width="100%",cols="2,5,^1,2",options="header"] +|=== +| Name | Description | Default | Type +| *uri* | *Required* Sets the uri of the endpoint to send to. | | String +| *ref* | *Deprecated* Sets the reference of the endpoint to send to. | | String +| *pattern* | Sets the optional ExchangePattern used to invoke this endpoint | | ExchangePattern +|=== +// eip options: END + +=== Samples + +The following example route demonstrates the use of a file consumer endpoint and a JMS producer endpoint. + +[source,java] +---- +from("file://local/router/messages/foo") + .to("jms:queue:foo"); +---- + +And in XML: + +[source,xml] +---- + + + + +---- + +=== to-eip with pattern + +Instead of using `inOnly` and `inOut` you may want to keep using `to` +where you can specify the exchange pattern as shown: + +[source,java] +---- +from("direct:startInOnly") + .to(ExchangePattern.InOnly, "bean:process"); + +from("direct:startInOut") + .to(ExchangePattern.InOut, "bean:process"); +---- + + +And here is how to do it in XML: + +[source,xml] +---- + + + + + + + + + +---- + +And here we use `` with the `pattern` attribute to set the exchange pattern: + +[source,xml] +---- + + + + + + + + + +---- \ No newline at end of file diff --git a/camel-core/src/main/docs/eips/toD-eip.adoc b/camel-core/src/main/docs/eips/toD-eip.adoc new file mode 100644 index 0000000000000..90aca441aa792 --- /dev/null +++ b/camel-core/src/main/docs/eips/toD-eip.adoc @@ -0,0 +1,117 @@ +[[toD-eip]] +== To D EIP + +There is a new `.toD` / `` that allows to send a message to a dynamic +computed link:endpoint.html[Endpoint] using one or +more link:expression.html[Expression] that are concat together. By +default the <> language is used to compute +the endpoint. + +=== Options + +// eip options: START +The To D EIP supports 4 options which are listed below: + + +[width="100%",cols="2,5,^1,2",options="header"] +|=== +| Name | Description | Default | Type +| *uri* | *Required* The uri of the endpoint to send to. The uri can be dynamic computed using the org.apache.camel.language.simple.SimpleLanguage expression. | | String +| *pattern* | Sets the optional ExchangePattern used to invoke this endpoint | | ExchangePattern +| *cacheSize* | Sets the maximum size used by the org.apache.camel.impl.ConsumerCache which is used to cache and reuse producers. | | Integer +| *ignoreInvalidEndpoint* | Ignore the invalidate endpoint exception when try to create a producer with that endpoint | false | Boolean +|=== +// eip options: END + +=== Samples + +For example to send a message to a endpoint defined by a +header you can do as shown below: + +[source,java] +---- +from("direct:start") + .toD("${header.foo}"); +---- + +And in XML: + +[source,xml] +---- + + + + +---- + +You can also prefix the uri with a value because by default the uri is +evaluated using the <> language + +[source,java] +---- +from("direct:start") + .toD("mock:${header.foo}"); +---- + +And in XML: + +[source,xml] +---- + + + + +---- + +In the example above we compute an endpoint that has prefix "mock:" and +then the header foo is appended. So for example if the header foo has +value order, then the endpoint is computed as "mock:order". + +You can also use other languages than <> such +as <> - this requires to prefix with language: as +shown below (simple language is the default language). If you do not +specify language: then the endpoint is a component name. And in some +cases there is both a component and language with the same name such as +xquery. + +[source,xml] +---- + + + + +---- + +This is done by specifying the name of the language followed by a colon. + +[source,java] +---- +from("direct:start") + .toD("language:xpath:/order/@uri"); +---- + +You can also concat multiple <>(s) together +using the plus sign `+` such as shown below: + +[source,xml] +---- + + + + +---- + +In the example above the uri is a combination +of <> language and <> where +the first part is simple (simple is default language). And then the plus +sign separate to another language, where we specify the language name +followed by a colon + +[source,java] +---- +from("direct:start") + .toD("jms:${header.base}+language:xpath:/order/@id"); +---- + +You can concat as many languages as you want, just separate them with +the plus sign diff --git a/camel-core/src/main/docs/eips/transform-eip.adoc b/camel-core/src/main/docs/eips/transform-eip.adoc new file mode 100644 index 0000000000000..7f9fc4fb45036 --- /dev/null +++ b/camel-core/src/main/docs/eips/transform-eip.adoc @@ -0,0 +1,12 @@ +[[transform-eip]] +== Transform EIP + +See below for details + +* link:https://github.com/apache/camel/blob/master/camel-core/src/main/docs/eips/message-translator.adoc[Message Translator] + +=== Options + +// eip options: START +The Transform EIP supports 0 options which are listed below: +// eip options: END