Repository: camel Updated Branches: refs/heads/master a3fffb9f8 -> 430af9a9a
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/430af9a9 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/430af9a9 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/430af9a9 Branch: refs/heads/master Commit: 430af9a9a328bd8de678102f619c19191033c6b2 Parents: a3fffb9 Author: Claus Ibsen <davscl...@apache.org> Authored: Wed Sep 20 13:50:13 2017 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Wed Sep 20 13:50:13 2017 +0200 ---------------------------------------------------------------------- camel-core/src/main/docs/eips/message-bus.adoc | 32 +----- .../src/main/docs/eips/message-channel.adoc | 39 +++---- .../src/main/docs/eips/message-endpoint.adoc | 112 ++++++++----------- .../src/main/docs/eips/message-router.adoc | 66 ++++++++--- .../src/main/docs/eips/message-translator.adoc | 62 ++++------ camel-core/src/main/docs/eips/message.adoc | 70 +++++++----- 6 files changed, 181 insertions(+), 200 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/430af9a9/camel-core/src/main/docs/eips/message-bus.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/eips/message-bus.adoc b/camel-core/src/main/docs/eips/message-bus.adoc index 8ad4ea8..ca93314 100644 --- a/camel-core/src/main/docs/eips/message-bus.adoc +++ b/camel-core/src/main/docs/eips/message-bus.adoc @@ -1,6 +1,5 @@ [[MessageBus-MessageBus]] -Message Bus -^^^^^^^^^^^ +== Message Bus Camel supports the http://www.enterpriseintegrationpatterns.com/PointToPointChannel.html[Message @@ -12,28 +11,14 @@ image:http://www.enterpriseintegrationpatterns.com/img/MessageBusSolution.gif[im Folks often assume that a Message Bus is a JMS though so you may wish to refer to the link:jms.html[JMS] component for traditional MOM support. + - Also worthy of note is the link:xmpp.html[XMPP] component for -supporting messaging over XMPP (Jabber) -Of course there are also ESB products such as -http://servicemix.apache.org/home.html[Apache ServiceMix] which serve as -full fledged message busses. + - You can interact with http://servicemix.apache.org/home.html[Apache -ServiceMix] from Camel in many ways, but in particular you can use the -link:nmr.html[NMR] or link:jbi.html[JBI] component to access the -ServiceMix message bus directly. - - [[MessageBus-Example]] -Example -+++++++ +=== Samples The following demonstrates how the Camel message bus can be used to communicate with consumers and producers -*Using the link:fluent-builders.html[Fluent Builders]* - [source,java] ----------------------------------------------- from("direct:start") @@ -41,7 +26,7 @@ from("direct:start") .to("jms:queue:foo"); ----------------------------------------------- -**Using the link:spring-xml-extensions.html[Spring XML Extensions]** +And in XML: [source,xml] ---------------------------------------------------- @@ -51,14 +36,3 @@ from("direct:start") <to uri="jms:queue:foo"/> </route> ---------------------------------------------------- - -[[MessageBus-UsingThisPattern]] -Using This Pattern -++++++++++++++++++ - -If you would like to use this EIP Pattern then please read the -link:getting-started.html[Getting Started], you may also find the -link:architecture.html[Architecture] useful particularly the description -of link:endpoint.html[Endpoint] and link:uris.html[URIs]. Then you could -try out some of the link:examples.html[Examples] first before trying -this pattern out. http://git-wip-us.apache.org/repos/asf/camel/blob/430af9a9/camel-core/src/main/docs/eips/message-channel.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/eips/message-channel.adoc b/camel-core/src/main/docs/eips/message-channel.adoc index 67c34e9..6fe2ed9 100644 --- a/camel-core/src/main/docs/eips/message-channel.adoc +++ b/camel-core/src/main/docs/eips/message-channel.adoc @@ -1,6 +1,5 @@ [[MessageChannel-MessageChannel]] -Message Channel -^^^^^^^^^^^^^^^ +== Message Channel Camel supports the http://www.enterpriseintegrationpatterns.com/MessageChannel.html[Message @@ -13,8 +12,7 @@ Endpoint interfaces. image:http://www.enterpriseintegrationpatterns.com/img/MessageChannelSolution.gif[image] - -*Example* +=== Samples In JMS, Message Channels are represented by topics and queues such as the following @@ -27,32 +25,27 @@ jms:queue:foo This message channel can be then used within the link:jms.html[JMS] component -*Using the link:fluent-builders.html[Fluent Builders]* +And the following shows a little Java route snippet: [source,java] -------------------- -to("jms:queue:foo") -------------------- +---- +from("direct:foo") + .to("jms:queue:foo") +---- -*Using the link:spring-xml-extensions.html[Spring XML Extensions]* +And in XML: [source,xml] -------------------------- -<to uri="jms:queue:foo"/> -------------------------- +---- +<route> + <from uri="direct:foo"> + <to uri="jms:queue:foo"/> +</route> +---- + +=== See Also For more details see * link:message.html[Message] * link:message-endpoint.html[Message Endpoint] - -[[MessageChannel-UsingThisPattern]] -Using This Pattern -++++++++++++++++++ - -If you would like to use this EIP Pattern then please read the -link:getting-started.html[Getting Started], you may also find the -link:architecture.html[Architecture] useful particularly the description -of link:endpoint.html[Endpoint] and link:uris.html[URIs]. Then you could -try out some of the link:examples.html[Examples] first before trying -this pattern out. http://git-wip-us.apache.org/repos/asf/camel/blob/430af9a9/camel-core/src/main/docs/eips/message-endpoint.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/eips/message-endpoint.adoc b/camel-core/src/main/docs/eips/message-endpoint.adoc index bb7bd5d..b88b998 100644 --- a/camel-core/src/main/docs/eips/message-endpoint.adoc +++ b/camel-core/src/main/docs/eips/message-endpoint.adoc @@ -1,6 +1,5 @@ [[MessageEndpoint-MessageEndpoint]] -Message Endpoint -^^^^^^^^^^^^^^^^ +== Message Endpoint Camel supports the http://www.enterpriseintegrationpatterns.com/MessageEndpoint.html[Message @@ -23,82 +22,73 @@ http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Compon implementations. [[MessageEndpoint-Example]] -Example -+++++++ +=== Samples -The following example route demonstrates the use of a -https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=38922[File] -Consumer Endpoint and link:jms.html[JMS] Producer Endpoint - -*Using the link:fluent-builders.html[Fluent Builders]* +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"); ----------------------------------------- +---- -**Using the link:spring-xml-extensions.html[Spring XML Extensions]** +And in XML: [source,xml] --------------------------------------------------- +---- <route> <from uri="file://local/router/messages/foo"/> <to uri="jms:queue:foo"/> </route> --------------------------------------------------- +---- - [[MessageEndpoint-DynamicTo]] -Dynamic To -^^^^^^^^^^ +=== Dynamic To *Available as of Camel 2.16* -There is a new <toD> that allows to send a message to a dynamic +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 link:simple.html[Simple] language is used to compute the endpoint. For example to send a message to a endpoint defined by a -header you can do +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> ----------------------------- +---- -And in Java DSL +You can also prefix the uri with a value because by default the uri is +evaluated using the link:simple.html[Simple] language [source,java] ------------------------- +---- from("direct:start") - .toD("${header.foo}"); ------------------------- + .toD("mock:${header.foo}"); +---- - - -You can also prefix the uri with a value because by default the uri is -evaluated using the link:simple.html[Simple] language +And in XML: [source,xml] --------------------------------- +---- <route> <from uri="direct:start"/> <toD uri="mock:${header.foo"/> </route> --------------------------------- - -And in Java DSL - -[source,java] ------------------------------ -from("direct:start") - .toD("mock:${header.foo}"); ------------------------------ +---- 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 @@ -112,31 +102,31 @@ 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 link:language.html[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 link:simple.html[Simple] language and link:xpath.html[XPath] where @@ -145,10 +135,10 @@ 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 @@ -156,37 +146,29 @@ 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 +| *uri* | | *Mandatory:* The uri to use. See above -|pattern | | To set a specific link:exchange-pattern.html[Exchange Pattern] to use +| *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 | | Allows to configure the cache size for the `ProducerCache` which caches +| *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 +| *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. -|======================================================================= - +|=== + -For more details see +=== See Also + +For more details see: * link:recipient-list.html[Recipient List] * link:message.html[Message] * link:wire-tap.html[Wire Tap] -[[MessageEndpoint-UsingThisPattern]] -Using This Pattern -++++++++++++++++++ - -If you would like to use this EIP Pattern then please read the -link:getting-started.html[Getting Started], you may also find the -link:architecture.html[Architecture] useful particularly the description -of link:endpoint.html[Endpoint] and link:uris.html[URIs]. Then you could -try out some of the link:examples.html[Examples] first before trying -this pattern out. http://git-wip-us.apache.org/repos/asf/camel/blob/430af9a9/camel-core/src/main/docs/eips/message-router.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/eips/message-router.adoc b/camel-core/src/main/docs/eips/message-router.adoc index 827f70c..861f12e 100644 --- a/camel-core/src/main/docs/eips/message-router.adoc +++ b/camel-core/src/main/docs/eips/message-router.adoc @@ -1,6 +1,5 @@ [[MessageRouter-MessageRouter]] -Message Router -^^^^^^^^^^^^^^ +== Message Router The http://www.enterpriseintegrationpatterns.com/MessageRouter.html[Message @@ -14,24 +13,59 @@ The following example shows how to route a request from an input *queue:a* endpoint to either *queue:b*, *queue:c* or *queue:d* depending on the evaluation of various link:predicate.html[Predicate] expressions -*Using the link:fluent-builders.html[Fluent Builders]* +=== Examples -*Using the link:spring-xml-extensions.html[Spring XML Extensions]* +The following example shows how to route a request from an input +*seda:a* endpoint to either *seda:b*, *seda:c* or *seda:d* depending on +the evaluation of various link:predicate.html[Predicate] expressions + +[source,java] +---- +RouteBuilder builder = new RouteBuilder() { + public void configure() { + from("direct:a") + .choice() + .when(simple("${header.foo} == 'bar'")) + .to("direct:b") + .when(simple("${header.foo} == 'cheese'")) + .to("direct:c") + .otherwise() + .to("direct:d"); + } +}; +---- + +TIP: See link:why-can-i-not-use-when-or-otherwise-in-a-java-camel-route.html[Why +can I not use when or otherwise in a Java Camel route] if you have +problems with the Java DSL, accepting using `when` or `otherwise`. + +And the same example using XML: + +[source,xml] +---- +<camelContext xmlns="http://camel.apache.org/schema/spring"> + <route> + <from uri="direct:a"/> + <choice> + <when> + <simple>${header.foo} == 'bar'</simple> + <to uri="direct:b"/> + </when> + <when> + <simple>${header.foo} == 'cheese'</simple> + <to uri="direct:c"/> + </when> + <otherwise> + <to uri="direct:d"/> + </otherwise> + </choice> + </route> +</camelContext> +---- [[MessageRouter-Choicewithoutotherwise]] -Choice without otherwise -++++++++++++++++++++++++ +=== Choice without otherwise If you use a `choice` without adding an `otherwise`, any unmatched exchanges will be dropped by default. -[[MessageRouter-UsingThisPattern]] -Using This Pattern -++++++++++++++++++ - -If you would like to use this EIP Pattern then please read the -link:getting-started.html[Getting Started], you may also find the -link:architecture.html[Architecture] useful particularly the description -of link:endpoint.html[Endpoint] and link:uris.html[URIs]. Then you could -try out some of the link:examples.html[Examples] first before trying -this pattern out. http://git-wip-us.apache.org/repos/asf/camel/blob/430af9a9/camel-core/src/main/docs/eips/message-translator.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/eips/message-translator.adoc b/camel-core/src/main/docs/eips/message-translator.adoc index 8d4d573..e35da4c 100644 --- a/camel-core/src/main/docs/eips/message-translator.adoc +++ b/camel-core/src/main/docs/eips/message-translator.adoc @@ -1,6 +1,5 @@ [[MessageTranslator-MessageTranslator]] -Message Translator -^^^^^^^^^^^^^^^^^^ +== Message Translator Camel supports the http://www.enterpriseintegrationpatterns.com/MessageTranslator.html[Message @@ -13,7 +12,7 @@ in different encodings. image:http://www.enterpriseintegrationpatterns.com/img/MessageTranslator.gif[image] -*Using the link:fluent-builders.html[Fluent Builders]* +=== Samples You can transform a message using Camel's link:bean-integration.html[Bean Integration] to call any method on a @@ -21,11 +20,11 @@ bean in your link:registry.html[Registry] such as your link:spring.html[Spring] XML configuration file as follows [source,java] ------------------------------------------------ -from("activemq:SomeQueue"). - beanRef("myTransformerBean", "myMethodName"). - to("mqseries:AnotherQueue"); ------------------------------------------------ +---- +from("activemq:SomeQueue") + .bean("myTransformerBean", "myMethodName") + .to("mqseries:AnotherQueue"); +---- Where the "myTransformerBean" would be defined in a Spring XML file or defined in JNDI etc. You can omit the method name parameter from @@ -37,8 +36,6 @@ the transformation or you can use the DSL to explicitly configure the transformation -*Use Spring XML* - You can also use link:spring-xml-extensions.html[Spring XML Extensions] to do a transformation. Basically any link:expression.html[Expression] language can be substituted inside the transform element as shown below @@ -46,14 +43,14 @@ language can be substituted inside the transform element as shown below Or you can use the link:bean-integration.html[Bean Integration] to invoke a bean -[source,java] ------------------------------------------------ +[source,xml] +---- <route> - <from uri="activemq:Input"/> - <bean ref="myBeanName" method="doTransform"/> - <to uri="activemq:Output"/> + <from uri="activemq:SomeQueue"/> + <bean ref="myTransformerBean" method="myMethodName"/> + <to uri="mqseries:AnotherQueue"/> </route> ------------------------------------------------ +---- You can also use link:templating.html[Templating] to consume a message from one destination, transform it with something like @@ -62,11 +59,11 @@ it on to another destination. For example using InOnly (one way messaging) [source,java] ----------------------------------------- -from("activemq:My.Queue"). - to("velocity:com/acme/MyResponse.vm"). - to("activemq:Another.Queue"); ----------------------------------------- +---- +from("activemq:My.Queue") + .to("velocity:com/acme/MyResponse.vm") + .to("activemq:Another.Queue"); +---- If you want to use InOut (request-reply) semantics to process requests on the *My.Queue* queue on link:activemq.html[ActiveMQ] with a template @@ -74,23 +71,8 @@ generated response, then sending responses back to the JMSReplyTo Destination you could use this. [source,java] ----------------------------------------- -from("activemq:My.Queue"). - to("velocity:com/acme/MyResponse.vm"); ----------------------------------------- - -[[MessageTranslator-UsingThisPattern]] -Using This Pattern -++++++++++++++++++ - -If you would like to use this EIP Pattern then please read the -link:getting-started.html[Getting Started], you may also find the -link:architecture.html[Architecture] useful particularly the description -of link:endpoint.html[Endpoint] and link:uris.html[URIs]. Then you could -try out some of the link:examples.html[Examples] first before trying -this pattern out. - -* link:content-enricher.html[Content Enricher] -* link:using-getin-or-getout-methods-on-exchange.html[Using getIn or -getOut methods on Exchange] +---- +from("activemq:My.Queue") + .to("velocity:com/acme/MyResponse.vm"); +---- http://git-wip-us.apache.org/repos/asf/camel/blob/430af9a9/camel-core/src/main/docs/eips/message.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/eips/message.adoc b/camel-core/src/main/docs/eips/message.adoc index c75a2bb..15c21e1 100644 --- a/camel-core/src/main/docs/eips/message.adoc +++ b/camel-core/src/main/docs/eips/message.adoc @@ -1,6 +1,5 @@ [[Message-Message]] -Message -^^^^^^^ +== Message Camel supports the http://www.enterpriseintegrationpatterns.com/Message.html[Message] from @@ -20,32 +19,45 @@ link:request-reply.html[Request Reply] where there is an inbound and outbound message. Here is a basic example of sending a Message to a route in *InOnly* and -*InOut* modes - -*Requestor Code* +*InOut* modes using a `ProducerTemplate` [source,java] ---------------------------------------------------------------------------------------------------------------- +---- //InOnly getContext().createProducerTemplate().sendBody("direct:startInOnly", "Hello World"); //InOut -String result = (String) getContext().createProducerTemplate().requestBody("direct:startInOut", "Hello World"); ---------------------------------------------------------------------------------------------------------------- +Object result = getContext().createProducerTemplate().requestBody("direct:startInOut", "Hello World"); +---- -*Route Using the link:fluent-builders.html[Fluent Builders]* +And an example with routes: [source,java] --------------------------------------------------- -from("direct:startInOnly").inOnly("bean:process"); +---- +from("direct:startInOnly") + .inOnly("bean:process"); -from("direct:startInOut").inOut("bean:process"); --------------------------------------------------- +from("direct:startInOut") + .inOut("bean:process"); +---- -*Route Using the link:spring-xml-extensions.html[Spring XML Extensions]* +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"/> @@ -55,15 +67,19 @@ from("direct:startInOut").inOut("bean:process"); <from uri="direct:startInOut"/> <inOut uri="bean:process"/> </route> ----------------------------------- - -[[Message-UsingThisPattern]] -Using This Pattern -++++++++++++++++++ - -If you would like to use this EIP Pattern then please read the -link:getting-started.html[Getting Started], you may also find the -link:architecture.html[Architecture] useful particularly the description -of link:endpoint.html[Endpoint] and link:uris.html[URIs]. Then you could -try out some of the link:examples.html[Examples] first before trying -this pattern out. +---- + +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> +----