[ https://issues.apache.org/jira/browse/CAMEL-11497?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16390865#comment-16390865 ]
ASF GitHub Bot commented on CAMEL-11497: ---------------------------------------- onderson closed pull request #2248: CAMEL-11497 - add missing to-eip.adoc toD-eip.adoc transform-eip.adoc… URL: https://github.com/apache/camel/pull/2248 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/camel-core/src/main/docs/eips/message-endpoint.adoc b/camel-core/src/main/docs/eips/message-endpoint.adoc index 3c37ff855d1..17bc4eda09b 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] ----- -<route> - <from uri="file://local/router/messages/foo"/> - <to uri="jms:queue:foo"/> -</route> ----- - - -[[MessageEndpoint-DynamicTo]] -=== Dynamic To - -*Available as of Camel 2.16* - -There is a new `.toD` / `<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 <<simple-language,Simple>> 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] ----- -<route> - <from uri="direct:start"/> - <toD uri="${header.foo}"/> -</route> ----- - -You can also prefix the uri with a value because by default the uri is -evaluated using the <<simple-language,Simple>> language - -[source,java] ----- -from("direct:start") - .toD("mock:${header.foo}"); ----- - -And in XML: - -[source,xml] ----- -<route> - <from uri="direct:start"/> - <toD uri="mock:${header.foo"/> -</route> ----- - -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 <<simple-language,Simple>> such -as <<xpath-language,XPath>> - 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] ----- -<route> - <from uri="direct:start"/> - <toD uri="language:xpath:/order/@uri"/> -</route> ----- - -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 <<language-component,Language>>(s) together -using the plus sign `+` such as shown below: - -[source,xml] ----- -<route> - <from uri="direct:start"/> - <toD uri="jms:${header.base}+language:xpath:/order/@id"/> -</route> ----- - -In the example above the uri is a combination -of <<simple-language,Simple>> language and <<simple-language,XPath>> 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 15c21e14fc5..1c89282f33f 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] ----- -<route> - <from uri="direct:startInOnly"/> - <inOnly uri="bean:process"/> -</route> - -<route> - <from uri="direct:startInOut"/> - <inOut uri="bean:process"/> -</route> ----- - -And here we use `<to>` with the `pattern` attribute to set the exchange pattern: - -[source,xml] ----- -<route> - <from uri="direct:startInOnly"/> - <to pattern="InOnly" uri="bean:process"/> -</route> - -<route> - <from uri="direct:startInOut"/> - <to pattern="InOut" uri="bean:process"/> -</route> ----- +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 00000000000..3dc8d23900a --- /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] +-------------------------------------------------------- +<bean id="myProcessor" class="com.acme.MyProcessor"/> +-------------------------------------------------------- + +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 00000000000..464f0995b24 --- /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] +---- +<route> + <from uri="file://local/router/messages/foo"/> + <to uri="jms:queue:foo"/> +</route> +---- + +=== 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] +---- +<route> + <from uri="direct:startInOnly"/> + <inOnly uri="bean:process"/> +</route> + +<route> + <from uri="direct:startInOut"/> + <inOut uri="bean:process"/> +</route> +---- + +And here we use `<to>` with the `pattern` attribute to set the exchange pattern: + +[source,xml] +---- +<route> + <from uri="direct:startInOnly"/> + <to pattern="InOnly" uri="bean:process"/> +</route> + +<route> + <from uri="direct:startInOut"/> + <to pattern="InOut" uri="bean:process"/> +</route> +---- \ 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 00000000000..90aca441aa7 --- /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` / `<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 <<simple-language,Simple>> 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] +---- +<route> + <from uri="direct:start"/> + <toD uri="${header.foo}"/> +</route> +---- + +You can also prefix the uri with a value because by default the uri is +evaluated using the <<simple-language,Simple>> language + +[source,java] +---- +from("direct:start") + .toD("mock:${header.foo}"); +---- + +And in XML: + +[source,xml] +---- +<route> + <from uri="direct:start"/> + <toD uri="mock:${header.foo"/> +</route> +---- + +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 <<simple-language,Simple>> such +as <<xpath-language,XPath>> - 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] +---- +<route> + <from uri="direct:start"/> + <toD uri="language:xpath:/order/@uri"/> +</route> +---- + +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 <<language-component,Language>>(s) together +using the plus sign `+` such as shown below: + +[source,xml] +---- +<route> + <from uri="direct:start"/> + <toD uri="jms:${header.base}+language:xpath:/order/@id"/> +</route> +---- + +In the example above the uri is a combination +of <<simple-language,Simple>> language and <<simple-language,XPath>> 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 00000000000..7f9fc4fb450 --- /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 ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Migrate the rest of the Confluence content > ------------------------------------------ > > Key: CAMEL-11497 > URL: https://issues.apache.org/jira/browse/CAMEL-11497 > Project: Camel > Issue Type: Sub-task > Components: website > Reporter: Zoran Regvart > Assignee: Önder Sezgin > Priority: Major > Fix For: Future > > > There are still pages in the Confluence that are not migrated to Asciidoctor -- This message was sent by Atlassian JIRA (v7.6.3#76005)