This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push: new 519f3a0 CAMEL-15302: Remove duplicate pages under eip section (#4015) 519f3a0 is described below commit 519f3a00ba012590d6b369340e3bd6ff2b1afcac Author: Aemie Jariwala <44139348+aem...@users.noreply.github.com> AuthorDate: Sun Jul 19 12:14:34 2020 +0530 CAMEL-15302: Remove duplicate pages under eip section (#4015) --- .../src/main/docs/modules/eips/nav.adoc | 2 - .../docs/modules/eips/pages/dynamic-router.adoc | 198 --------------------- .../docs/modules/eips/pages/dynamicRouter-eip.adoc | 91 +++++++--- .../pages/enterprise-integration-patterns.adoc | 2 +- .../docs/modules/eips/pages/request-reply.adoc | 44 ----- .../docs/modules/eips/pages/requestReply-eip.adoc | 1 + 6 files changed, 67 insertions(+), 271 deletions(-) diff --git a/core/camel-core-engine/src/main/docs/modules/eips/nav.adoc b/core/camel-core-engine/src/main/docs/modules/eips/nav.adoc index 54ad1c9..7471262 100644 --- a/core/camel-core-engine/src/main/docs/modules/eips/nav.adoc +++ b/core/camel-core-engine/src/main/docs/modules/eips/nav.adoc @@ -21,7 +21,6 @@ ** xref:eips:dead-letter-channel.adoc[Dead Letter Channel] ** xref:eips:delay-eip.adoc[Delay] ** xref:eips:durable-subscriber.adoc[Durable Subscriber] - ** xref:eips:dynamic-router.adoc[Dynamic Router] ** xref:eips:dynamicRouter-eip.adoc[Dynamic Router] ** xref:eips:enrich-eip.adoc[Enrich] ** xref:eips:eventDrivenConsumer-eip.adoc[Event Driven Consumer] @@ -72,7 +71,6 @@ ** xref:eips:removeHeaders-eip.adoc[Remove Headers] ** xref:eips:removeProperties-eip.adoc[Remove Properties] ** xref:eips:removeProperty-eip.adoc[Remove Property] - ** xref:eips:request-reply.adoc[Request Reply] ** xref:eips:requestReply-eip.adoc[Request Reply] ** xref:eips:resequence-eip.adoc[Resequence] ** xref:eips:resilience4jConfiguration-eip.adoc[Resilience4j Configuration] diff --git a/core/camel-core-engine/src/main/docs/modules/eips/pages/dynamic-router.adoc b/core/camel-core-engine/src/main/docs/modules/eips/pages/dynamic-router.adoc deleted file mode 100644 index 6bd839f..0000000 --- a/core/camel-core-engine/src/main/docs/modules/eips/pages/dynamic-router.adoc +++ /dev/null @@ -1,198 +0,0 @@ -[[DynamicRouter-DynamicRouter]] -= Dynamic Router - -The -http://www.enterpriseintegrationpatterns.com/DynamicRouter.html[Dynamic -Router] from the EIP patterns -allows you to route messages while avoiding the dependency of the router -on all possible destinations while maintaining its efficiency. - -image::eip/DynamicRouter.gif[image] - -The `dynamicRouter` in the DSL is similar to -a dynamic Routing Slip which evaluates the slip -_on-the-fly_. - -WARNING: *Beware* -You must ensure the expression used for the `dynamicRouter` such as a -bean, will return `null` to indicate the end. Otherwise the -`dynamicRouter` will keep repeating endlessly. - -[[DynamicRouter-DynamicRouterinCamel2.5onwards]] -== Dynamic Router in Camel 2.5 onwards - -The Dynamic Router will set a -property (Exchange.SLIP_ENDPOINT) on the Exchange -which contains the current endpoint as it advanced though the slip. This -allows you to know how far we have processed in the slip. (It's a slip -because the Dynamic Router implementation is -based on top of Routing Slip). - -TIP: See the `cacheSize` option for more details on _how much cache_ to use depending on how many or few unique endpoints are used. - -== Options - -// eip options: START -The Dynamic Router EIP supports 3 options which are listed below: - -[width="100%",cols="2,5,^1,2",options="header"] -|=== -| Name | Description | Default | Type -| *uriDelimiter* | Sets the uri delimiter to use | , | String -| *ignoreInvalidEndpoints* | Ignore the invalidate endpoint exception when try to create a producer with that endpoint | false | Boolean -| *cacheSize* | Sets the maximum size used by the org.apache.camel.spi.ProducerCache which is used to cache and reuse producers when using this routing slip, when uris are reused. Beware that when using dynamic endpoints then it affects how well the cache can be utilized. If each dynamic endpoint is unique then its best to turn of caching by setting this to -1, which allows Camel to not cache both the producers and endpoints; they are regarded as prototype scoped and will be stopped and [...] -|=== -// eip options: END - -[[DynamicRouter-JavaDSL]] -== Java DSL - -In Java DSL you can use the `dynamicRouter` as shown below: - -[source,java] ----- -from("direct:start") - // use a bean as the dynamic router - .dynamicRouter(method(DynamicRouterTest.class, "slip")); ----- - -Which will leverage a xref:components::bean-component.adoc[Bean] to compute the slip -_on-the-fly_, which could be implemented as follows: - -[source,java] ----- -/** - * Use this method to compute dynamic where we should route next. - * - * @param body the message body - * @return endpoints to go, or <tt>null</tt> to indicate the end - */ -public String slip(String body) { - bodies.add(body); - invoked++; - - if (invoked == 1) { - return "mock:a"; - } else if (invoked == 2) { - return "mock:b,mock:c"; - } else if (invoked == 3) { - return "direct:foo"; - } else if (invoked == 4) { - return "mock:result"; - } - - // no more so return null - return null; -} ----- - -Mind that this example is only for show and tell. The current -implementation is not thread safe. You would have to store the state on -the Exchange, to ensure thread safety, as shown -below: - -[source,java] ----- -/** - * Use this method to compute dynamic where we should route next. - * - * @param body the message body - * @param properties the exchange properties where we can store state between invocations - * @return endpoints to go, or <tt>null</tt> to indicate the end - */ -public String slip(String body, @Properties Map<String, Object> properties) { - bodies.add(body); - - // get the state from the exchange properties and keep track how many times - // we have been invoked - int invoked = 0; - Object current = properties.get("invoked"); - if (current != null) { - invoked = Integer.valueOf(current.toString()); - } - invoked++; - // and store the state back on the properties - properties.put("invoked", invoked); - - if (invoked == 1) { - return "mock:a"; - } else if (invoked == 2) { - return "mock:b,mock:c"; - } else if (invoked == 3) { - return "direct:foo"; - } else if (invoked == 4) { - return "mock:result"; - } - - // no more so return null - return null; -} ----- - -You could also store state as message headers, but they are not -guaranteed to be preserved during routing, where as properties on the -Exchange are. Although there was a bug in the method -call expression, see the warning below. - -[[DynamicRouter-SpringXML]] -== Spring XML - -The same example in Spring XML would be: - -[source,xml] ----- -<bean id="mySlip" class="org.apache.camel.processor.DynamicRouterTest"/> - -<camelContext xmlns="http://camel.apache.org/schema/spring"> - <route> - <from uri="direct:start"/> - <dynamicRouter> - <!-- use a method call on a bean as dynamic router --> - <method ref="mySlip" method="slip"/> - </dynamicRouter> - </route> - - <route> - <from uri="direct:foo"/> - <transform><constant>Bye World</constant></transform> - </route> - -</camelContext> ----- - -[[DynamicRouter-DynamicRouterannotation]] -== @DynamicRouter annotation - -You can also use the `@DynamicRouter` annotation. The `route` method would -then be invoked repeatedly as the message is processed dynamically. The -idea is to return the next endpoint uri where to go. Return `null` to -indicate the end. You can return multiple endpoints if you like, just as -the Routing Slip, where each endpoint is -separated by a delimiter. - -[source,java] ----- -public class MyDynamicRouter { - - @Consume(uri = "activemq:foo") - @DynamicRouter - public String route(@XPath("/customer/id") String customerId, @Header("Location") String location, Document body) { - // query a database to find the best match of the endpoint based on the input parameteres - // return the next endpoint uri, where to go. Return null to indicate the end. - } -} ----- - -In the above we can use the -Parameter Binding Annotations -to bind different parts of the Message to method -parameters or use an Expression such as using -xref:components:languages:xpath-language.adoc[XPath] or xref:components:languages:xpath-language.adoc[XQuery]. - -The method can be invoked in a number of ways as described in the -Bean Integration such as - -* POJO Producing -* Spring Remoting -* xref:components::bean-component.adoc[Bean] component - diff --git a/core/camel-core-engine/src/main/docs/modules/eips/pages/dynamicRouter-eip.adoc b/core/camel-core-engine/src/main/docs/modules/eips/pages/dynamicRouter-eip.adoc index cf3264e..c404f5f 100644 --- a/core/camel-core-engine/src/main/docs/modules/eips/pages/dynamicRouter-eip.adoc +++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/dynamicRouter-eip.adoc @@ -5,7 +5,11 @@ :since: :supportLevel: Stable -The http://www.enterpriseintegrationpatterns.com/DynamicRouter.html[Dynamic Router] from the xref:enterprise-integration-patterns.adoc[EIP patterns] allows you to route messages while avoiding the dependency of the router on all possible destinations while maintaining its efficiency. +The +http://www.enterpriseintegrationpatterns.com/DynamicRouter.html[Dynamic +Router] from the EIP patterns +allows you to route messages while avoiding the dependency of the router +on all possible destinations while maintaining its efficiency. image::eip/DynamicRouter.gif[image] @@ -13,11 +17,20 @@ The `dynamicRouter` in the DSL is similar to a dynamic Routing Slip which evaluates the slip _on-the-fly_. -[IMPORTANT] -.Avoid endless looping -=== -You must ensure the expression used for the `dynamicRouter` such as a bean, will return `null` to indicate the end. Otherwise the `dynamicRouter` will keep repeating endlessly. -=== +WARNING: *Beware* +You must ensure the expression used for the `dynamicRouter` such as a +bean, will return `null` to indicate the end. Otherwise the +`dynamicRouter` will keep repeating endlessly. + +[[DynamicRouter-DynamicRouterinCamel2.5onwards]] +== Dynamic Router in Camel 2.5 onwards + +The Dynamic Router will set a +property (Exchange.SLIP_ENDPOINT) on the Exchange +which contains the current endpoint as it advanced though the slip. This +allows you to know how far we have processed in the slip. (It's a slip +because the Dynamic Router implementation is +based on top of Routing Slip). TIP: See the `cacheSize` option for more details on _how much cache_ to use depending on how many or few unique endpoints are used. @@ -30,15 +43,13 @@ The Dynamic Router EIP supports 3 options which are listed below: |=== | Name | Description | Default | Type | *uriDelimiter* | Sets the uri delimiter to use | , | String -| *ignoreInvalidEndpoints* | Ignore the invalidate endpoint exception when try to create a producer with that endpoint | | String -| *cacheSize* | Sets the maximum size used by the org.apache.camel.spi.ProducerCache which is used to cache and reuse producers when using this dynamic router, when uris are reused. Beware that when using dynamic endpoints then it affects how well the cache can be utilized. If each dynamic endpoint is unique then its best to turn of caching by setting this to -1, which allows Camel to not cache both the producers and endpoints; they are regarded as prototype scoped and will be stopped an [...] +| *ignoreInvalidEndpoints* | Ignore the invalidate endpoint exception when try to create a producer with that endpoint | false | Boolean +| *cacheSize* | Sets the maximum size used by the org.apache.camel.spi.ProducerCache which is used to cache and reuse producers when using this routing slip, when uris are reused. Beware that when using dynamic endpoints then it affects how well the cache can be utilized. If each dynamic endpoint is unique then its best to turn of caching by setting this to -1, which allows Camel to not cache both the producers and endpoints; they are regarded as prototype scoped and will be stopped and [...] |=== // eip options: END -The Dynamic Router will set the property `Exchange.SLIP_ENDPOINT` on the Exchange which contains the current endpoint as it advanced though the slip. This allows you to know how far we have processed in the slip. -(It's a slip because the Dynamic Router implementation is based on top of Routing Slip). - -== Samples +[[DynamicRouter-JavaDSL]] +== Java DSL In Java DSL you can use the `dynamicRouter` as shown below: @@ -49,7 +60,8 @@ from("direct:start") .dynamicRouter(method(DynamicRouterTest.class, "slip")); ---- -Which will leverage a Bean to compute the slip _on-the-fly_, which could be implemented as follows: +Which will leverage a xref:components::bean-component.adoc[Bean] to compute the slip +_on-the-fly_, which could be implemented as follows: [source,java] ---- @@ -62,7 +74,7 @@ Which will leverage a Bean to compute the slip _on-the-fly_, which could be impl public String slip(String body) { bodies.add(body); invoked++; - + if (invoked == 1) { return "mock:a"; } else if (invoked == 2) { @@ -72,13 +84,16 @@ public String slip(String body) { } else if (invoked == 4) { return "mock:result"; } - + // no more so return null return null; } ---- -Mind that this example is only for show and tell. The current implementation is not thread safe. You would have to store the state on the Exchange, to ensure thread safety, as shown below: +Mind that this example is only for show and tell. The current +implementation is not thread safe. You would have to store the state on +the Exchange, to ensure thread safety, as shown +below: [source,java] ---- @@ -91,7 +106,7 @@ Mind that this example is only for show and tell. The current implementation is */ public String slip(String body, @Properties Map<String, Object> properties) { bodies.add(body); - + // get the state from the exchange properties and keep track how many times // we have been invoked int invoked = 0; @@ -102,7 +117,7 @@ public String slip(String body, @Properties Map<String, Object> properties) { invoked++; // and store the state back on the properties properties.put("invoked", invoked); - + if (invoked == 1) { return "mock:a"; } else if (invoked == 2) { @@ -112,21 +127,26 @@ public String slip(String body, @Properties Map<String, Object> properties) { } else if (invoked == 4) { return "mock:result"; } - + // no more so return null return null; } ---- -You could also store state as message headers, but they are not guaranteed to be preserved during routing, where as properties on the Exchange are. Although there was a bug in the method call expression, see the warning below. +You could also store state as message headers, but they are not +guaranteed to be preserved during routing, where as properties on the +Exchange are. Although there was a bug in the method +call expression, see the warning below. + +[[DynamicRouter-SpringXML]] +== Spring XML -=== Spring XML The same example in Spring XML would be: [source,xml] ---- <bean id="mySlip" class="org.apache.camel.processor.DynamicRouterTest"/> - + <camelContext xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="direct:start"/> @@ -135,18 +155,24 @@ The same example in Spring XML would be: <method ref="mySlip" method="slip"/> </dynamicRouter> </route> - + <route> <from uri="direct:foo"/> <transform><constant>Bye World</constant></transform> </route> - + </camelContext> ---- +[[DynamicRouter-DynamicRouterannotation]] == @DynamicRouter annotation -You can also use the `@DynamicRouter` annotation. The `route` method would then be invoked repeatedly as the message is processed dynamically. -The idea is to return the next endpoint uri where to go. Return `null` to indicate the end. You can return multiple endpoints if you like, just as the Routing Slip, where each endpoint is separated by a delimiter. + +You can also use the `@DynamicRouter` annotation. The `route` method would +then be invoked repeatedly as the message is processed dynamically. The +idea is to return the next endpoint uri where to go. Return `null` to +indicate the end. You can return multiple endpoints if you like, just as +the Routing Slip, where each endpoint is +separated by a delimiter. [source,java] ---- @@ -160,3 +186,16 @@ public class MyDynamicRouter { } } ---- + +In the above we can use the +Parameter Binding Annotations +to bind different parts of the Message to method +parameters or use an Expression such as using +xref:components:languages:xpath-language.adoc[XPath] or xref:components:languages:xpath-language.adoc[XQuery]. + +The method can be invoked in a number of ways as described in the +Bean Integration such as + +* POJO Producing +* Spring Remoting +* xref:components::bean-component.adoc[Bean] component diff --git a/core/camel-core-engine/src/main/docs/modules/eips/pages/enterprise-integration-patterns.adoc b/core/camel-core-engine/src/main/docs/modules/eips/pages/enterprise-integration-patterns.adoc index ea10721..98b3279 100644 --- a/core/camel-core-engine/src/main/docs/modules/eips/pages/enterprise-integration-patterns.adoc +++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/enterprise-integration-patterns.adoc @@ -92,7 +92,7 @@ a|image::eip/EventMessageIcon.gif[image] transmit events from one application to another? a|image::eip/RequestReplyIcon.gif[image] -|xref:request-reply.adoc[Request Reply] |When an application sends a +|xref:requestReply-eip.adoc[Request Reply] |When an application sends a message, how can it get a response from the receiver? a|image::eip/ReturnAddressIcon.gif[image] diff --git a/core/camel-core-engine/src/main/docs/modules/eips/pages/request-reply.adoc b/core/camel-core-engine/src/main/docs/modules/eips/pages/request-reply.adoc deleted file mode 100644 index 907a9f2..0000000 --- a/core/camel-core-engine/src/main/docs/modules/eips/pages/request-reply.adoc +++ /dev/null @@ -1,44 +0,0 @@ -[[request-reply]] -= Request Reply -:page-source: core/camel-core-engine/src/main/docs/eips/request-reply.adoc - -Camel supports the -http://www.enterpriseintegrationpatterns.com/RequestReply.html[Request -Reply] from the EIP patterns -by supporting the Exchange Pattern on a -Message which can be set to *InOut* to indicate a -request/reply. Camel Components then implement -this pattern using the underlying transport or protocols. - -image::eip/RequestReply.gif[image] - -For example when using xref:components::jms-component.adoc[JMS] with InOut the component will -by default perform these actions - -* create by default a temporary inbound queue -* set the JMSReplyTo destination on the request message -* set the JMSCorrelationID on the request message -* send the request message -* consume the response and associate the inbound message to the request -using the JMSCorrelationID (as you may be performing many concurrent -request/responses). - -TIP: *Related* See the related Event Message message - -[[RequestReply-ExplicitlyspecifyingInOut]] -== Explicitly specifying InOut - -When consuming messages from xref:components::jms-component.adoc[JMS] a Request-Reply is -indicated by the presence of the *JMSReplyTo* header. - -You can explicitly force an endpoint to be in Request Reply mode by -setting the exchange pattern on the URI. e.g. - -[source,text] ----- -jms:MyQueue?exchangePattern=InOut ----- - -You can specify the exchange pattern in DSL rule or Spring -configuration. - diff --git a/core/camel-core-engine/src/main/docs/modules/eips/pages/requestReply-eip.adoc b/core/camel-core-engine/src/main/docs/modules/eips/pages/requestReply-eip.adoc index 9a96feb..191881d 100644 --- a/core/camel-core-engine/src/main/docs/modules/eips/pages/requestReply-eip.adoc +++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/requestReply-eip.adoc @@ -1,5 +1,6 @@ [[requestReply-eip]] = Request Reply +:page-source: core/camel-core-engine/src/main/docs/eips/requestreply-eip.adoc Camel supports the http://www.enterpriseintegrationpatterns.com/RequestReply.html[Request