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/2cc68570 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2cc68570 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2cc68570 Branch: refs/heads/master Commit: 2cc685701d40bb167b1fe223d2f6dd20ba74553f Parents: 19fcfa8 Author: Claus Ibsen <davscl...@apache.org> Authored: Tue Sep 19 14:22:02 2017 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Tue Sep 19 14:22:02 2017 +0200 ---------------------------------------------------------------------- camel-core/src/main/docs/mock-component.adoc | 29 +- camel-core/src/main/docs/ref-component.adoc | 54 ++- camel-core/src/main/docs/ref-language.adoc | 10 +- camel-core/src/main/docs/request-reply.adoc | 29 +- .../src/main/docs/rest-api-component.adoc | 352 +++++++++---------- camel-core/src/main/docs/rest-component.adoc | 103 +++--- camel-core/src/main/docs/return-address.adoc | 29 +- .../src/main/docs/scheduler-component.adoc | 41 +-- camel-core/src/main/docs/seda-component.adoc | 57 ++- .../src/main/docs/serialization-dataformat.adoc | 4 +- camel-core/src/main/docs/string-dataformat.adoc | 8 +- camel-core/src/main/docs/stub-component.adoc | 22 +- camel-core/src/main/docs/test-component.adoc | 19 +- camel-core/src/main/docs/timer-component.adoc | 66 ++-- camel-core/src/main/docs/transformer.adoc | 83 ++--- .../src/main/docs/validator-component.adoc | 16 +- camel-core/src/main/docs/validator.adoc | 101 +++--- camel-core/src/main/docs/vm-component.adoc | 29 +- camel-core/src/main/docs/xpath-language.adoc | 123 ++++--- camel-core/src/main/docs/xslt-component.adoc | 147 ++++---- camel-core/src/main/docs/zip-dataformat.adoc | 12 +- 21 files changed, 599 insertions(+), 735 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/2cc68570/camel-core/src/main/docs/mock-component.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/mock-component.adoc b/camel-core/src/main/docs/mock-component.adoc index 66f3936..f8d34db 100644 --- a/camel-core/src/main/docs/mock-component.adoc +++ b/camel-core/src/main/docs/mock-component.adoc @@ -129,10 +129,10 @@ test has run, we assert that our expectations have been met: ---- MockEndpoint resultEndpoint = context.resolveEndpoint("mock:foo", MockEndpoint.class); +// set expectations resultEndpoint.expectedMessageCount(2); // send some messages -... // now lets assert that the mock:foo endpoint received 2 messages resultEndpoint.assertIsSatisfied(); @@ -146,7 +146,7 @@ Camel will by default wait 10 seconds when the `assertIsSatisfied()` is invoked. This can be configured by setting the `setResultWaitTime(millis)` method. -#=== Using `assertPeriod` +=== Using assertPeriod *Available as of Camel 2.7* + When the assertion is satisfied then Camel will stop waiting and @@ -163,7 +163,6 @@ resultEndpoint.setAssertPeriod(5000); resultEndpoint.expectedMessageCount(2); // send some messages -... // now lets assert that the mock:foo endpoint received 2 messages resultEndpoint.assertIsSatisfied(); @@ -177,7 +176,7 @@ the various helper methods you can use to set expectations. The main methods are as follows: [width="100%",cols="1m,1",options="header",] -|======================================================================= +|=== |Method |Description |http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/component/mock/MockEndpoint.html#expectedMessageCount(int)[expectedMessageCount(int)] |To define the expected message count on the endpoint. @@ -204,7 +203,7 @@ given link:expression.html[Expression] to compare messages. link:expression.html[Expression] to calculate a unique identifier for each message. This could be something like the `JMSMessageID` if using JMS, or some unique reference number within the message. -|======================================================================= +|=== Here's another example: @@ -213,7 +212,7 @@ Here's another example: resultEndpoint.expectedBodiesReceived("firstMessageBody", "secondMessageBody", "thirdMessageBody"); ---- -#=== Adding expectations to specific messages +=== Adding expectations to specific messages In addition, you can use the http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/component/mock/MockEndpoint.html#message(int)[`message(int @@ -241,10 +240,7 @@ Camel now allows you to automatically mock existing endpoints in your Camel routes. [NOTE] -*How it works* + - + -*Important:* The endpoints are still in action. + -What happens differently +*How it works* The endpoints are still in action. What happens differently is that a link:mock.html[Mock] endpoint is injected and receives the message first and then delegates the message to the target endpoint. You can view this as a kind of intercept and delegate or endpoint listener. @@ -302,7 +298,7 @@ That means Camel will use more memory. This may not be suitable when you send in a lot of messages. -#=== Mocking existing endpoints using the `camel-test` component +=== Mocking existing endpoints using the `camel-test` component Instead of using the `adviceWith` to instruct Camel to mock endpoints, you can easily enable this behavior when using the `camel-test` Test @@ -322,7 +318,7 @@ include::../../../../components/camel-test/src/test/java/org/apache/camel/test/p ---- -#=== Mocking existing endpoints with XML DSL +=== Mocking existing endpoints with XML DSL If you do not use the `camel-test` component for unit testing (as shown above) you can use a different approach when using XML files for @@ -362,7 +358,7 @@ in the constructor for the bean: </bean> ---- -#=== Mocking endpoints and skip sending to original endpoint +=== Mocking endpoints and skip sending to original endpoint *Available as of Camel 2.10* @@ -409,8 +405,6 @@ first 5 and last 5 link:exchange.html[Exchange]s the mock receives. mock.setRetainLast(5); mock.expectedMessageCount(2000); - ... - mock.assertIsSatisfied(); ---- @@ -483,10 +477,5 @@ In the example above we use `seconds` as the time unit, but Camel offers === See Also -* link:configuring-camel.html[Configuring Camel] -* link:component.html[Component] -* link:endpoint.html[Endpoint] -* link:getting-started.html[Getting Started] - * link:spring-testing.html[Spring Testing] * link:testing.html[Testing] http://git-wip-us.apache.org/repos/asf/camel/blob/2cc68570/camel-core/src/main/docs/ref-component.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/ref-component.adoc b/camel-core/src/main/docs/ref-component.adoc index 4bfdd45..7e7bbe2 100644 --- a/camel-core/src/main/docs/ref-component.adoc +++ b/camel-core/src/main/docs/ref-component.adoc @@ -7,10 +7,10 @@ the link:registry.html[Registry]. === URI format -[source,java] ----------------------- +[source] +---- ref:someName[?options] ----------------------- +---- Where *someName* is the name of an endpoint in the link:registry.html[Registry] (usually, but not always, the Spring @@ -61,30 +61,28 @@ in the link:registry.html[Registry] where you can compute the URI at runtime. Then you can look up the endpoint using the following code: [source,java] -------------------------------------------------------------------- - // lookup the endpoint - String myEndpointRef = "bigspenderOrder"; - Endpoint endpoint = context.getEndpoint("ref:" + myEndpointRef); - - Producer producer = endpoint.createProducer(); - Exchange exchange = producer.createExchange(); - exchange.getIn().setBody(payloadToSend); - // send the exchange - producer.process(exchange); - ... -------------------------------------------------------------------- +---- +// lookup the endpoint +String myEndpointRef = "bigspenderOrder"; +Endpoint endpoint = context.getEndpoint("ref:" + myEndpointRef); + +Producer producer = endpoint.createProducer(); +Exchange exchange = producer.createExchange(); +exchange.getIn().setBody(payloadToSend); +// send the exchange +producer.process(exchange); +---- And you could have a list of endpoints defined in the link:registry.html[Registry] such as: [source,xml] ----------------------------------------------------------------------------------- - <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"> - <endpoint id="normalOrder" uri="activemq:order.slow"/> - <endpoint id="bigspenderOrder" uri="activemq:order.high"/> - ... - </camelContext> ----------------------------------------------------------------------------------- +---- +<camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"> + <endpoint id="normalOrder" uri="activemq:order.slow"/> + <endpoint id="bigspenderOrder" uri="activemq:order.high"/> +</camelContext> +---- === Sample @@ -94,15 +92,9 @@ endpoint with the spring ID, `endpoint2`: You could, of course, have used the `ref` attribute instead: [source,xml] ---------------------------- - <to ref="endpoint2"/> ---------------------------- +---- +<to ref="endpoint2"/> +---- Which is the more common way to write it. -=== See Also - -* link:configuring-camel.html[Configuring Camel] -* link:component.html[Component] -* link:endpoint.html[Endpoint] -* link:getting-started.html[Getting Started] http://git-wip-us.apache.org/repos/asf/camel/blob/2cc68570/camel-core/src/main/docs/ref-language.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/ref-language.adoc b/camel-core/src/main/docs/ref-language.adoc index c324c12..a553b8e 100644 --- a/camel-core/src/main/docs/ref-language.adoc +++ b/camel-core/src/main/docs/ref-language.adoc @@ -27,11 +27,9 @@ The link:splitter.html[Splitter] in XML DSL can utilize a custom expression using `<ref>` like: [source,xml] ------------------------------------------------------------------- +---- <bean id="myExpression" class="com.mycompany.MyCustomExpression"/> -... - <route> <from uri="seda:a"/> <split> @@ -39,7 +37,7 @@ expression using `<ref>` like: <to uri="mock:b"/> </split> </route> ------------------------------------------------------------------- +---- in this case, the link:message.html[Message] coming from the seda:a link:endpoint.html[Endpoint] will be splitted using a custom @@ -49,9 +47,9 @@ link:registry.html[Registry]. And the same example using Java DSL: [source,java] --------------------------------------------------------- +---- from("seda:a").split().ref("myExpression").to("seda:b"); --------------------------------------------------------- +---- === Dependencies http://git-wip-us.apache.org/repos/asf/camel/blob/2cc68570/camel-core/src/main/docs/request-reply.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/request-reply.adoc b/camel-core/src/main/docs/request-reply.adoc index 8cf4582..339c7fd 100644 --- a/camel-core/src/main/docs/request-reply.adoc +++ b/camel-core/src/main/docs/request-reply.adoc @@ -1,6 +1,5 @@ [[RequestReply-RequestReply]] -Request Reply -~~~~~~~~~~~~~ +== Request Reply Camel supports the http://www.enterpriseintegrationpatterns.com/RequestReply.html[Request @@ -23,16 +22,10 @@ by default perform these actions using the JMSCorrelationID (as you may be performing many concurrent request/responses). -[TIP] -==== -*Related* - -See the related link:event-message.html[Event Message] message -==== +TIP: *Related* See the related link:event-message.html[Event Message] message [[RequestReply-ExplicitlyspecifyingInOut]] -Explicitly specifying InOut -^^^^^^^^^^^^^^^^^^^^^^^^^^^ +=== Explicitly specifying InOut When consuming messages from link:jms.html[JMS] a Request-Reply is indicated by the presence of the *JMSReplyTo* header. @@ -40,21 +33,11 @@ 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,java] ---------------------------------- +[source] +---- jms:MyQueue?exchangePattern=InOut ---------------------------------- +---- You can specify the exchange pattern in DSL rule or Spring configuration. -[[RequestReply-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/2cc68570/camel-core/src/main/docs/rest-api-component.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/rest-api-component.adoc b/camel-core/src/main/docs/rest-api-component.adoc index eec1fe6..479cddf 100644 --- a/camel-core/src/main/docs/rest-api-component.adoc +++ b/camel-core/src/main/docs/rest-api-component.adoc @@ -45,31 +45,31 @@ A simple REST service can be define as follows, where we use rest() to define the services as shown below: [source,java] ------------------------------------------------------------------------------- - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - rest("/say") - .get("/hello").to("direct:hello") - .get("/bye").consumes("application/json").to("direct:bye") - .post("/bye").to("mock:update"); - - from("direct:hello") - .transform().constant("Hello World"); - from("direct:bye") - .transform().constant("Bye World"); - } - }; - } ------------------------------------------------------------------------------- +---- +protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + rest("/say") + .get("/hello").to("direct:hello") + .get("/bye").consumes("application/json").to("direct:bye") + .post("/bye").to("mock:update"); + + from("direct:hello") + .transform().constant("Hello World"); + from("direct:bye") + .transform().constant("Bye World"); + } + }; +} +----  This defines a REST service with the following url mappings: [width="100%",cols="25%,25%,25%,25%",options="header",] -|======================================================================= +|=== |Base Path |Uri template |Verb |Consumes |/say |/hello |get |_all_ @@ -77,7 +77,7 @@ This defines a REST service with the following url mappings: |/say |/bye |get |application/json |/say |/bye |post |_all_ -|======================================================================= +|=== Notice that in the REST service we route directly to a Camel endpoint using the to(). This is because the Rest DSL has a short-hand for @@ -90,36 +90,34 @@ below. The REST DSL supports the XML DSL also using either Spring or Blueprint. The example above can be define in XML as shown below: -[source,java] --------------------------------------------------------------- - <camelContext xmlns="http://camel.apache.org/schema/spring"> - <rest path="/say"> - <get uri="/hello"> - <to uri="direct:hello"/> - </get> - <get uri="/bye" consumes="application/json"> - <to uri="direct:bye"/> - </get> - <post uri="/bye"> - <to uri="mock:update"/> - </post> - </rest> - <route> - <from uri="direct:hello"/> - <transform> - <constant>Hello World</constant> - </transform> - </route> - <route> - <from uri="direct:bye"/> - <transform> - <constant>Bye World</constant> - </transform> - </route> - </camelContext> --------------------------------------------------------------- - - +[source,xml] +---- +<camelContext xmlns="http://camel.apache.org/schema/spring"> + <rest path="/say"> + <get uri="/hello"> + <to uri="direct:hello"/> + </get> + <get uri="/bye" consumes="application/json"> + <to uri="direct:bye"/> + </get> + <post uri="/bye"> + <to uri="mock:update"/> + </post> + </rest> + <route> + <from uri="direct:hello"/> + <transform> + <constant>Hello World</constant> + </transform> + </route> + <route> + <from uri="direct:bye"/> + <transform> + <constant>Bye World</constant> + </transform> + </route> +</camelContext> +---- === Using base path @@ -129,31 +127,29 @@ rest("/customer") and then provide the uri templates in the verbs, as shown below: [source,java] -------------------------------------------------------- - rest("/customers/") - .get("/{id}").to("direct:customerDetail") - .get("/{id}/orders").to("direct:customerOrders") - .post("/neworder").to("direct:customerNewOrder"); -------------------------------------------------------- - - +---- +rest("/customers/") + .get("/{id}").to("direct:customerDetail") + .get("/{id}/orders").to("direct:customerOrders") + .post("/neworder").to("direct:customerNewOrder"); +---- And using XML DSL it becomes: -[source,java] -------------------------------------------- - <rest path="/customers/"> - <get uri="/{id}"> - <to uri="direct:customerDetail"/> - </get> - <get uri="/{id}/orders"> - <to uri="direct:customerOrders"/> - </get> - <post uri="/neworder"> - <to uri="direct:customerNewOrder"/> - </post> - </rest> -------------------------------------------- +[source,xml] +---- +<rest path="/customers/"> + <get uri="/{id}"> + <to uri="direct:customerDetail"/> + </get> + <get uri="/{id}/orders"> + <to uri="direct:customerOrders"/> + </get> + <post uri="/neworder"> + <to uri="direct:customerNewOrder"/> + </post> +</rest> +---- TIP:The REST DSL will take care of duplicate path separators when using base path and uri templates. In the example above the rest base path ends @@ -164,22 +160,22 @@ It is not required to use both base path and uri templates. You can omit the bast path and define the base path and uri template in the verbs only. The example above can be defined as: -[source,java] -------------------------------------------- - <rest> - <get uri="/customers/{id}"> - <to uri="direct:customerDetail"/> - </get> - <get uri="/customers/{id}/orders"> - <to uri="direct:customerOrders"/> - </get> - <post uri="/customers/neworder"> - <to uri="direct:customerNewOrder"/> - </post> - </rest> -------------------------------------------- - -=== Using Dynamic To +[source,xml] +---- +<rest> + <get uri="/customers/{id}"> + <to uri="direct:customerDetail"/> + </get> + <get uri="/customers/{id}/orders"> + <to uri="direct:customerOrders"/> + </get> + <post uri="/customers/neworder"> + <to uri="direct:customerNewOrder"/> + </post> +</rest> +---- + +=== Using Dynamic To in Rest DSL *Available as of Camel 2.16* @@ -187,26 +183,24 @@ The link:rest-dsl.html[Rest DSL] supports the new .toD <toD> as dynamic to in the rest-dsl. For example to do a request/reply over link:jms.html[JMS] where the queue name is dynamic defined -[source,xml] -------------------------------------------------------------------------- +[source,java] +---- public void configure() throws Exception { rest("/say") .get("/hello/{language}").toD("jms:queue:hello-${header.language}"); } -------------------------------------------------------------------------- +---- === And in XML DSL [source,xml] ---------------------------------------------------- +---- <rest uri="/say"> <get uri="/hello//{language}"> <toD uri="jms:queue:hello-${header.language}"/> </get> <rest> ---------------------------------------------------- - - +---- See more details at link:message-endpoint.html[Message Endpoint] about the dynamic to, and what syntax it supports. By default it uses @@ -230,33 +224,37 @@ why we end up with 3 + 2 = 5 total routes. The same example could use embedded Camel routes, which is shown below: [source,java] ------------------------------------------------------------------------------------------------------------ - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - rest("/say/hello") - .get().route().transform().constant("Hello World"); - rest("/say/bye") - .get().consumes("application/json").route().transform().constant("Bye World").endRest() - .post().to("mock:update"); - }; - } ------------------------------------------------------------------------------------------------------------ +---- +protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + rest("/say/hello") + .get().route().transform().constant("Hello World"); + rest("/say/bye") + .get().consumes("application/json").route().transform().constant("Bye World").endRest() + .post().to("mock:update"); + }; +} +---- In the example above, we are embedding routes directly in the rest service using .route(). Notice we need to use .endRest() to tell Camel where the route ends, so we can _go back_ to the Rest DSL and continue defining REST services. -TIP:*Configuring route options* +#### Configuring route options In the embedded route you can configure the route settings such as routeId, autoStartup and various other options you can set on routes today. ---------------------------------------------------------------------------------------------- -.get().route().routeId("myRestRoute").autoStartup(false).transform().constant("Hello World"); ---------------------------------------------------------------------------------------------- + +[source,java] +---- +.get() + .route().routeId("myRestRoute").autoStartup(false) + .transform().constant("Hello World"); +---- === Managing Rest services @@ -288,7 +286,7 @@ work with the POJOs in Java code. The binding modes are: [width="100%",cols="10%,90%",options="header",] -|======================================================================= +|=== |Binding Mode |Description |off |Binding is turned off. This is the default option. @@ -307,7 +305,7 @@ classpath. See the INFO box below for more details. |json_xml |Binding to/from json and xml is enabled and requires both data formats to be on the classpath. See the INFO box below for more details. -|======================================================================= +|=== TIP:From *Camel 2.14.1* onwards when using camel-jaxb for xml bindings, then you can use the option `mustBeJAXBElement` to relax the output message @@ -332,18 +330,16 @@ rest configuration, and then override per rest service as well. To enable binding you configure this in Java DSL as shown below [source,java] ------------------------------------------------------------------------------------------------------------ +---- restConfiguration().component("restlet").host("localhost").port(portNum).bindingMode(RestBindingMode.auto); ------------------------------------------------------------------------------------------------------------ +---- And in XML DSL -[source,java] ---------------------------------------------------------------------------- - <restConfiguration bindingMode="auto" component="restlet" port="8080"/> ---------------------------------------------------------------------------- - - +[source,xml] +---- +<restConfiguration bindingMode="auto" component="restlet" port="8080"/> +---- When binding is enabled Camel will bind the incoming and outgoing messages automatic, accordingly to the content type of the message. If @@ -353,7 +349,7 @@ messages. The table below summaries what binding occurs for incoming and reply messages. [width="100%",cols="25%,25%,25%,25%",options="header",] -|======================================================================= +|=== |Message Body |Direction |Binding Mode |Message Body |XML |Incoming |auto, @@ -370,7 +366,7 @@ json_xml |POJO |POJO |Outgoing |auto, json, json_xml |JSON -|======================================================================= +|===  When using binding you must also configure what POJO type to map to. This is mandatory for incoming messages, and optional for outgoing. @@ -379,7 +375,7 @@ For example to map from xml/json to a pojo class `UserPojo` you do this in Java DSL as shown below: [source,java] ------------------------------------------------------------------------------------------------------------ +---- // configure to use restlet on localhost with the given port // and enable auto binding mode restConfiguration().component("restlet").host("localhost").port(portNum).bindingMode(RestBindingMode.auto); @@ -388,7 +384,7 @@ restConfiguration().component("restlet").host("localhost").port(portNum).binding rest("/users/") .post().type(UserPojo.class) .to("direct:newUser"); ------------------------------------------------------------------------------------------------------------ +---- Notice we use `type` to define the incoming type. We can optionally define an outgoing type (which can be a good idea, to make it known from @@ -397,7 +393,7 @@ outgoing types of the REST services.). To define the outgoing type, we use `outType` as shown below: [source,java] ------------------------------------------------------------------------------------------------------------ +---- // configure to use restlet on localhost with the given port // and enable auto binding mode restConfiguration().component("restlet").host("localhost").port(portNum).bindingMode(RestBindingMode.auto); @@ -406,13 +402,13 @@ restConfiguration().component("restlet").host("localhost").port(portNum).binding rest("/users/") .post().type(UserPojo.class).outType(CountryPojo.class) .to("direct:newUser"); ------------------------------------------------------------------------------------------------------------ +---- To specify input and/or output using an array, append `[]` to the end of the canonical class name as shown in the following Java DSL: [source,java] ------------------------------------------------------------------------------------------------------------ +---- // configure to use restlet on localhost with the given port // and enable auto binding mode restConfiguration().component("restlet").host("localhost").port(portNum).bindingMode(RestBindingMode.auto); @@ -421,12 +417,12 @@ restConfiguration().component("restlet").host("localhost").port(portNum).binding rest("/users/") .post().type(UserPojo[].class).outType(CountryPojo[].class) .to("direct:newUser"); ------------------------------------------------------------------------------------------------------------ +---- The `UserPojo` is just a plain pojo with getter/setter as shown: [source,java] --------------------------------------- +---- public class UserPojo { private int id; private String name; @@ -443,14 +439,14 @@ public class UserPojo { this.name = name; } } --------------------------------------- +---- The `UserPojo` only supports json, as XML requires to use JAXB annotations, so we can add those annotations if we want to support XML also [source,java] --------------------------------------- +---- @XmlRootElement(name = "user") @XmlAccessorType(XmlAccessType.FIELD) public class UserPojo { @@ -471,7 +467,7 @@ public class UserPojo { this.name = name; } } --------------------------------------- +---- By having the JAXB annotations the POJO supports both json and xml bindings. @@ -548,27 +544,27 @@ input has a property which cannot be mapped to a POJO) then configure this using the dataFormatProperty as shown below: [source,java] ----------------------------------------------------------------------------------------------------------- +---- restConfiguration().component("jetty").host("localhost").port(getPort()).bindingMode(RestBindingMode.json) .dataFormatProperty("json.in.disableFeatures", "FAIL_ON_UNKNOWN_PROPERTIES"); ----------------------------------------------------------------------------------------------------------- +---- You can disable more features by separating the values using comma, such as: [source,java] ------------------------------------------------------------------------------------------------------------------- - .dataFormatProperty("json.in.disableFeatures", "FAIL_ON_UNKNOWN_PROPERTIES,ADJUST_DATES_TO_CONTEXT_TIME_ZONE"); ------------------------------------------------------------------------------------------------------------------- +---- +.dataFormatProperty("json.in.disableFeatures", "FAIL_ON_UNKNOWN_PROPERTIES,ADJUST_DATES_TO_CONTEXT_TIME_ZONE"); +---- Likewise you can enable features using the enableFeatures such as: [source,java] ------------------------------------------------------------------------------------------------------------------ +---- restConfiguration().component("jetty").host("localhost").port(getPort()).bindingMode(RestBindingMode.json) .dataFormatProperty("json.in.disableFeatures", "FAIL_ON_UNKNOWN_PROPERTIES,ADJUST_DATES_TO_CONTEXT_TIME_ZONE") .dataFormatProperty("json.in.enableFeatures", "FAIL_ON_NUMBERS_FOR_ENUMS,USE_BIG_DECIMAL_FOR_FLOATS"); ------------------------------------------------------------------------------------------------------------------ +---- The values that can be used for enabling and disabling features on Jackson are the names of the enums from the following three Jackson @@ -578,19 +574,15 @@ classes * com.fasterxml.jackson.databind.DeserializationFeature * com.fasterxml.jackson.databind.MapperFeature - - The rest configuration is of course also possible using XML DSL [source,xml] --------------------------------------------------------------------------------------------------------------------------- +---- <restConfiguration component="jetty" host="localhost" port="9090" bindingMode="json"> <dataFormatProperty key="json.in.disableFeatures" value="FAIL_ON_UNKNOWN_PROPERTIES,ADJUST_DATES_TO_CONTEXT_TIME_ZONE"/> <dataFormatProperty key="json.in.enableFeatures" value="FAIL_ON_NUMBERS_FOR_ENUMS,USE_BIG_DECIMAL_FOR_FLOATS"/> </restConfiguration> --------------------------------------------------------------------------------------------------------------------------- - - +---- === Default CORS headers @@ -601,7 +593,7 @@ configure custom CORS headers which takes precedence over the default value. [width="100%",cols="50%,50%",options="header",] -|======================================================================= +|=== |Key |Value |Access-Control-Allow-Origin |* @@ -612,7 +604,7 @@ value. Access-Control-Request-Method, Access-Control-Request-Headers |Access-Control-Max-Age |3600 -|======================================================================= +|===  === Defining a custom error message as-is @@ -625,25 +617,25 @@ set the content-type header as well. There is a little example shown below: [source,java] ---------------------------------------------------------------------------------------------------------------------------- - restConfiguration().component("restlet").host("localhost").port(portNum).bindingMode(RestBindingMode.json); - // use the rest DSL to define the rest services - rest("/users/") - .post("lives").type(UserPojo.class).outType(CountryPojo.class) - .route() - .choice() - .when().simple("${body.id} < 100") - .bean(new UserErrorService(), "idToLowError") - .otherwise() - .bean(new UserService(), "livesWhere"); ---------------------------------------------------------------------------------------------------------------------------- +---- +restConfiguration().component("restlet").host("localhost").port(portNum).bindingMode(RestBindingMode.json); +// use the rest DSL to define the rest services +rest("/users/") + .post("lives").type(UserPojo.class).outType(CountryPojo.class) + .route() + .choice() + .when().simple("${body.id} < 100") + .bean(new UserErrorService(), "idToLowError") + .otherwise() + .bean(new UserService(), "livesWhere"); +---- In this example if the input id is a number that is below 100, we want to send back a custom error message, using the UserErrorService bean, which is implemented as shown: [source,java] ------------------------------------------------------------------------- +---- public class UserErrorService { public void idToLowError(Exchange exchange) { exchange.getIn().setBody("id value is too low"); @@ -651,7 +643,7 @@ public class UserErrorService { exchange.getIn().setHeader(Exchange.HTTP_RESPONSE_CODE, 400); } } ------------------------------------------------------------------------- +---- In the UserErrorService bean we build our custom error message, and set the HTTP error code to 400. This is important, as that tells rest-dsl @@ -667,15 +659,13 @@ response message. For example to return a HTTP error code 400 with a hardcoded message, we can do as shown below: [source,java] -------------------------------------------------------------- +---- onException(JsonParseException.class) .handled(true) .setHeader(Exchange.HTTP_RESPONSE_CODE, constant(400)) .setHeader(Exchange.CONTENT_TYPE, constant("text/plain")) .setBody().constant("Invalid json data"); -------------------------------------------------------------- - - +---- === Query Parameter default Values @@ -683,14 +673,14 @@ You can specify default values for parameters in the rest-dsl, such as the verbose parameter below: [source,java] --------------------------------------------------------------------------------------------------------------------------------- +---- rest("/customers/") .get("/{id}").to("direct:customerDetail") .get("/{id}/orders") .param().name("verbose").type(RestParamType.query).defaultValue("false").description("Verbose order details").endParam() .to("direct:customerOrders") .post("/neworder").to("direct:customerNewOrder"); --------------------------------------------------------------------------------------------------------------------------------- +---- From *Camel 2.17* onwards then the default value is automatic set as header on the incoming Camel `Message`. So if the call @@ -724,56 +714,48 @@ on, using the <param>. For example to define the id path parameter you can do as shown below: [source,xml] ---------------------------------------------------------------------------------------- +---- <!-- this is a rest GET to view an user by the given id --> <get uri="/{id}" outType="org.apache.camel.example.rest.User"> <description>Find user by id</description> <param name="id" type="path" description="The id of the user to get" dataType="int"/> <to uri="bean:userService?method=getUser(${header.id})"/> </get> ---------------------------------------------------------------------------------------- +---- And in Java DSL [source,java] ------------------------------------------------------------------------------------------------------- +---- .get("/{id}").description("Find user by id").outType(User.class) .param().name("id").type(path).description("The id of the user to get").dataType("int").endParam() .to("bean:userService?method=getUser(${header.id})") ------------------------------------------------------------------------------------------------------- +---- The body parameter type requires to use body as well for the name. For example a REST PUT operation to create/update an user could be done as: [source,xml] ------------------------------------------------------------------------------ +---- <!-- this is a rest PUT to create/update an user --> <put type="org.apache.camel.example.rest.User"> <description>Updates or create a user</description> <param name="body" type="body" description="The user to update or create"/> <to uri="bean:userService?method=updateUser"/> </put> ------------------------------------------------------------------------------ +---- And in Java DSL [source,java] -------------------------------------------------------------------------------------------- +---- .put().description("Updates or create a user").type(User.class) .param().name("body").type(body).description("The user to update or create").endParam() .to("bean:userService?method=updateUser") -------------------------------------------------------------------------------------------- - - +---- -For an example see the `examples/camel-example-servlet-rest-tomcat` of -the Apache Camel distribution. === See Also -* link:dsl.html[DSL] * link:rest.html[Rest] * link:swagger-java.html[Swagger Java] -* link:spark-rest.html[Spark-rest] -* link:how-do-i-import-rests-from-other-xml-files.html[How do I import -rests from other XML files] http://git-wip-us.apache.org/repos/asf/camel/blob/2cc68570/camel-core/src/main/docs/rest-component.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/rest-component.adoc b/camel-core/src/main/docs/rest-component.adoc index 81265a3..e0bbb8c 100644 --- a/camel-core/src/main/docs/rest-component.adoc +++ b/camel-core/src/main/docs/rest-component.adoc @@ -10,10 +10,10 @@ From Camel 2.18 onwards the rest component can also be used as a client (produce === URI format -[source,java] --------------------------------------------- - rest://method:path[:uriTemplate]?[options] --------------------------------------------- +[source] +---- +rest://method:path[:uriTemplate]?[options] +---- === URI Options @@ -109,31 +109,31 @@ practice with REST. The following is a Camel route using a a path only [source,java] ---------------------------------------- - from("rest:get:hello") - .transform().constant("Bye World"); ---------------------------------------- +---- +from("rest:get:hello") + .transform().constant("Bye World"); +---- And the following route uses a parameter which is mapped to a Camel header with the key "me". [source,java] --------------------------------------------- - from("rest:get:hello/{me}") - .transform().simple("Bye ${header.me}"); --------------------------------------------- +---- +from("rest:get:hello/{me}") + .transform().simple("Bye ${header.me}"); +---- The following examples have configured a base path as "hello" and then have two REST services configured using uriTemplates. [source,java] ------------------------------------------------- - from("rest:get:hello:/{me}") - .transform().simple("Hi ${header.me}"); - - from("rest:get:hello:/french/{me}") - .transform().simple("Bonjour ${header.me}"); ------------------------------------------------- +---- +from("rest:get:hello:/{me}") + .transform().simple("Hi ${header.me}"); + +from("rest:get:hello:/french/{me}") + .transform().simple("Bonjour ${header.me}"); +---- === Rest producer examples @@ -142,48 +142,48 @@ You can use the rest component to call REST services like any other Camel compon For example to call a REST service on using `hello/{me}` you can do [source,java] --------------------------------------------- - from("direct:start") - .to("rest:get:hello/{me}"); --------------------------------------------- +---- +from("direct:start") + .to("rest:get:hello/{me}"); +---- And then the dynamic value `{me}` is mapped to Camel message with the same name. So to call this REST service you can send an empty message body and a header as shown: [source,java] --------------------------------------------- - template.sendBodyAndHeader("direct:start", null, "me", "Donald Duck"); --------------------------------------------- +---- +template.sendBodyAndHeader("direct:start", null, "me", "Donald Duck"); +---- The Rest producer needs to know the hostname and port of the REST service, which you can configure using the host option as shown: [source,java] --------------------------------------------- - from("direct:start") - .to("rest:get:hello/{me}?host=myserver:8080/foo"); --------------------------------------------- +---- +from("direct:start") + .to("rest:get:hello/{me}?host=myserver:8080/foo"); +---- Instead of using the host option, you can configure the host on the `restConfiguration` as shown: [source,java] --------------------------------------------- - restConfiguration().host("myserver:8080/foo"); +---- +restConfiguration().host("myserver:8080/foo"); - from("direct:start") - .to("rest:get:hello/{me}"); --------------------------------------------- +from("direct:start") + .to("rest:get:hello/{me}"); +---- You can use the `producerComponent` to select which Camel component to use as the HTTP client, for example to use http4 you can do: [source,java] --------------------------------------------- - restConfiguration().host("myserver:8080/foo").producerComponent("http4"); +---- +restConfiguration().host("myserver:8080/foo").producerComponent("http4"); - from("direct:start") - .to("rest:get:hello/{me}"); --------------------------------------------- +from("direct:start") + .to("rest:get:hello/{me}"); +---- === Rest producer binding @@ -193,23 +193,23 @@ The REST producer supports binding using JSon or XML like the rest-dsl does. For example to use jetty with json binding mode turned on you can configure this in the rest configuration: [source,java] --------------------------------------------- - restConfiguration().component("jetty").host("localhost").port(8080).bindingMode(RestBindingMode.json); +---- +restConfiguration().component("jetty").host("localhost").port(8080).bindingMode(RestBindingMode.json); - from("direct:start") - .to("rest:post:user"); --------------------------------------------- +from("direct:start") + .to("rest:post:user"); +---- Then when calling the REST service using rest producer it will automatic bind any POJOs to json before calling the REST service: [source,java] --------------------------------------------- +---- UserPojo user = new UserPojo(); user.setId(123); user.setName("Donald Duck"); template.sendBody("direct:start", user); --------------------------------------------- +---- In the example above we send a POJO instance `UserPojo` as the message body. And because we have turned on JSon binding in the rest configuration, then the POJO will be marshalled from POJO to JSon before calling the REST service. @@ -220,12 +220,12 @@ would need to configure the `outType` option to specify what is the classname of For example if the REST service returns a JSon payload that binds to `com.foo.MyResponsePojo` you can configure this as shown: [source,java] --------------------------------------------- +---- restConfiguration().component("jetty").host("localhost").port(8080).bindingMode(RestBindingMode.json); from("direct:start") .to("rest:post:user?outType=com.foo.MyResponsePojo"); --------------------------------------------- +---- IMPORTANT: You must configure `outType` option if you want POJO binding to happen for the response messages received from calling the REST service. @@ -243,10 +243,5 @@ containers. === See Also -* link:configuring-camel.html[Configuring Camel] -* link:component.html[Component] -* link:endpoint.html[Endpoint] -* link:getting-started.html[Getting Started] - * link:rest-dsl.html[Rest DSL] * link:servlet.html[SERVLET] http://git-wip-us.apache.org/repos/asf/camel/blob/2cc68570/camel-core/src/main/docs/return-address.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/return-address.adoc b/camel-core/src/main/docs/return-address.adoc index 536b2c4..c0c5e6f5 100644 --- a/camel-core/src/main/docs/return-address.adoc +++ b/camel-core/src/main/docs/return-address.adoc @@ -13,24 +13,27 @@ by default return to the address given in `JMSReplyTo`. *Requestor Code* [source,java] -------------------------------------------------------------------------------- -getMockEndpoint("mock:bar").expectedBodiesReceived("Bye World"); +---- +getMockEndpoint("queue:bar").expectedBodiesReceived("Bye World"); + template.sendBodyAndHeader("direct:start", "World", "JMSReplyTo", "queue:bar"); -------------------------------------------------------------------------------- +---- *Route Using the link:fluent-builders.html[Fluent Builders]* [source,java] ----------------------------------------------------------------------- +---- from("direct:start").to("activemq:queue:foo?preserveMessageQos=true"); + from("activemq:queue:foo").transform(body().prepend("Bye ")); + from("activemq:queue:bar?disableReplyTo=true").to("mock:bar"); ----------------------------------------------------------------------- +---- *Route Using the link:spring-xml-extensions.html[Spring XML Extensions]* -[source,java] --------------------------------------------------------- +[source,xml] +---- <route> <from uri="direct:start"/> <to uri="activemq:queue:foo?preserveMessageQos=true"/> @@ -47,19 +50,9 @@ from("activemq:queue:bar?disableReplyTo=true").to("mock:bar"); <from uri="activemq:queue:bar?disableReplyTo=true"/> <to uri="mock:bar"/> </route> --------------------------------------------------------- +---- For a complete example of this pattern, see this http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsInOnlyWithReplyToAsHeaderTest.java?view=markup[junit test case] -[[ReturnAddress-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/2cc68570/camel-core/src/main/docs/scheduler-component.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/scheduler-component.adoc b/camel-core/src/main/docs/scheduler-component.adoc index 3cf2be0..2ec55f8 100644 --- a/camel-core/src/main/docs/scheduler-component.adoc +++ b/camel-core/src/main/docs/scheduler-component.adoc @@ -12,10 +12,10 @@ You can only consume events from this endpoint. === URI format -[source,java] ------------------------- +[source] +---- scheduler:name[?options] ------------------------- +---- Where `name` is the name of the scheduler, which is created and shared across endpoints. So if you use the same name for all your timer @@ -104,24 +104,22 @@ When the timer is fired, it adds the following information as properties to the `Exchange`: [width="100%",cols="10%,10%,80%",options="header",] -|======================================================================= +|=== |Name |Type |Description |`Exchange.TIMER_NAME` |`String` |The value of the `name` option. |`Exchange.TIMER_FIRED_TIME` |`Date` |The time when the consumer fired. -|======================================================================= +|=== === Sample To set up a route that generates an event every 60 seconds: [source,java] ------------------------------------------------------------------------------- - from("scheduler://foo?period=60s").to("bean:myBean?method=someMethodName"); ------------------------------------------------------------------------------- - - +---- +from("scheduler://foo?period=60s").to("bean:myBean?method=someMethodName"); +---- The above route will generate an event and then invoke the `someMethodName` method on the bean called `myBean` in the @@ -130,19 +128,17 @@ link:registry.html[Registry] such as JNDI or link:spring.html[Spring]. And the route in Spring DSL: [source,xml] -------------------------------------------------- - <route> - <from uri="scheduler://foo?period=60s"/> - <to uri="bean:myBean?method=someMethodName"/> - </route> -------------------------------------------------- - - +---- +<route> + <from uri="scheduler://foo?period=60s"/> + <to uri="bean:myBean?method=someMethodName"/> +</route> +---- === Forcing the scheduler to trigger immediately when completed To let the scheduler trigger as soon as the previous task is complete, -you can set the option greedy=true. But beware then the scheduler will +you can set the option `greedy=true`. But beware then the scheduler will keep firing all the time. So use this with caution. === Forcing the scheduler to be idle @@ -159,14 +155,7 @@ The consumer will otherwise as by default return 1 message polled to the scheduler, every time the consumer has completed processing the exchange. - - === See Also -* link:configuring-camel.html[Configuring Camel] -* link:component.html[Component] -* link:endpoint.html[Endpoint] -* link:getting-started.html[Getting Started] - * link:timer.html[Timer] * link:quartz.html[Quartz] http://git-wip-us.apache.org/repos/asf/camel/blob/2cc68570/camel-core/src/main/docs/seda-component.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/seda-component.adoc b/camel-core/src/main/docs/seda-component.adoc index e74494a..b747858 100644 --- a/camel-core/src/main/docs/seda-component.adoc +++ b/camel-core/src/main/docs/seda-component.adoc @@ -24,10 +24,10 @@ of any consumers when a producer sends a message exchange. === URI format -[source,java] ------------------------ +[source] +---- seda:someName[?options] ------------------------ +---- Where *someName* can be any string that uniquely identifies the endpoint within the current link:camelcontext.html[CamelContext]. @@ -103,30 +103,32 @@ By default, the SEDA component always intantiates LinkedBlockingQueue, but you can use different implementation, you can reference your own BlockingQueue implementation, in this case the size option is not used -[source,java] ------------------------------------------------------------ +[source,xml] +---- <bean id="arrayQueue" class="java.util.ArrayBlockingQueue"> -<constructor-arg index="0" value="10" ><!-- size --> -<constructor-arg index="1" value="true" ><!-- fairness --> + <constructor-arg index="0" value="10" ><!-- size --> + <constructor-arg index="1" value="true" ><!-- fairness --> </bean> + <!-- ... and later --> <from>seda:array?queue=#arrayQueue</from> ------------------------------------------------------------ +---- Or you can reference a BlockingQueueFactory implementation, 3 implementations are provided LinkedBlockingQueueFactory, ArrayBlockingQueueFactory and PriorityBlockingQueueFactory: -[source,java] ------------------------------------------------------------------------------------------------------ +[source,xml] +---- <bean id="priorityQueueFactory" class="org.apache.camel.component.seda.PriorityBlockingQueueFactory"> -<property name="comparator"> -<bean class="org.apache.camel.demo.MyExchangeComparator" /> -</property> + <property name="comparator"> + <bean class="org.apache.camel.demo.MyExchangeComparator" /> + </property> </bean> + <!-- ... and later --> <from>seda:priority?queueFactory=#priorityQueueFactory&size=100</from> ------------------------------------------------------------------------------------------------------ +---- === Use of Request Reply @@ -135,11 +137,11 @@ link:request-reply.html[Request Reply], where the caller will wait for the link:async.html[Async] route to complete. For instance: [source,java] -------------------------------------------------------------------------- +---- from("mina:tcp://0.0.0.0:9876?textline=true&sync=true").to("seda:input"); from("seda:input").to("bean:processInput").to("bean:createResponse"); -------------------------------------------------------------------------- +---- In the route above, we have a TCP listener on port 9876 that accepts incoming requests. The request is routed to the `seda:input` queue. As @@ -147,7 +149,7 @@ it is a link:request-reply.html[Request Reply] message, we wait for the response. When the consumer on the `seda:input` queue is complete, it copies the response to the original message response. -NOTE:*until 2.2: Works only with 2 endpoints* +NOTE: *until 2.2: Works only with 2 endpoints* Using link:request-reply.html[Request Reply] over link:seda.html[SEDA] or link:vm.html[VM] only works with 2 endpoints. You *cannot* chain endpoints by sending to A -> B -> C etc. Only between A -> B. The reason @@ -164,9 +166,9 @@ configure it to use concurrent consumer threads. So instead of thread pools you can use: [source,java] ---------------------------------------------------------- +---- from("seda:stageName?concurrentConsumers=5").process(...) ---------------------------------------------------------- +---- As for the difference between the two, note a _thread pool_ can increase/shrink dynamically at runtime depending on load, whereas the @@ -178,9 +180,9 @@ Be aware that adding a thread pool to a SEDA endpoint by doing something like: [source,java] ---------------------------------------------- +---- from("seda:stageName").thread(5).process(...) ---------------------------------------------- +---- Can wind up with two `BlockQueues`: one from the SEDA endpoint, and one from the workqueue of the thread pool, which may not be what you want. @@ -189,9 +191,9 @@ with a thread pool, which can process messages both synchronously and asynchronously. For example: [source,java] ------------------------------------------------ +---- from("direct:stageName").thread(5).process(...) ------------------------------------------------ +---- You can also directly configure number of threads that process messages on a SEDA endpoint using the `concurrentConsumers` option. @@ -231,18 +233,13 @@ If needed, information such as queue size, etc. can be obtained without using JMX in this fashion: [source,java] ------------------------------------------------------ +---- SedaEndpoint seda = context.getEndpoint("seda:xxxx"); int size = seda.getExchanges().size(); ------------------------------------------------------ +---- === See Also -* link:configuring-camel.html[Configuring Camel] -* link:component.html[Component] -* link:endpoint.html[Endpoint] -* link:getting-started.html[Getting Started] - * link:vm.html[VM] * link:disruptor.html[Disruptor] * link:direct.html[Direct] http://git-wip-us.apache.org/repos/asf/camel/blob/2cc68570/camel-core/src/main/docs/serialization-dataformat.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/serialization-dataformat.adoc b/camel-core/src/main/docs/serialization-dataformat.adoc index 2025de8..7485590 100644 --- a/camel-core/src/main/docs/serialization-dataformat.adoc +++ b/camel-core/src/main/docs/serialization-dataformat.adoc @@ -9,11 +9,11 @@ Java objects or to marshal Java objects into a binary blob. + file then send it as an ObjectMessage to link:activemq.html[ActiveMQ] [source,java] ------------------------------- +---- from("file://foo/bar"). unmarshal().serialization(). to("activemq:Some.Queue"); ------------------------------- +---- === Options http://git-wip-us.apache.org/repos/asf/camel/blob/2cc68570/camel-core/src/main/docs/string-dataformat.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/string-dataformat.adoc b/camel-core/src/main/docs/string-dataformat.adoc index 0ef323d..2c6129f 100644 --- a/camel-core/src/main/docs/string-dataformat.adoc +++ b/camel-core/src/main/docs/string-dataformat.adoc @@ -26,9 +26,9 @@ In this example we marshal the file content to String object in UTF-8 encoding. [source,java] ----------------------------------------------------------------------- +---- from("file://data.csv").marshal().string("UTF-8").to("jms://myqueue"); ----------------------------------------------------------------------- +---- === Unmarshal @@ -37,9 +37,9 @@ object using UTF-8 encoding, before its processed by the newOrder processor. [source,java] ------------------------------------------------------------------------------ +---- from("jms://queue/order").unmarshal().string("UTF-8").processRef("newOrder"); ------------------------------------------------------------------------------ +---- === Dependencies http://git-wip-us.apache.org/repos/asf/camel/blob/2cc68570/camel-core/src/main/docs/stub-component.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/stub-component.adoc b/camel-core/src/main/docs/stub-component.adoc index e543150..84f4474 100644 --- a/camel-core/src/main/docs/stub-component.adoc +++ b/camel-core/src/main/docs/stub-component.adoc @@ -18,10 +18,10 @@ route temporarily. === URI format -[source,java] ------------- +[source] +---- stub:someUri ------------- +---- Where *`someUri`* can be any URI with any query parameters. @@ -87,15 +87,11 @@ with the following path and query parameters: === Examples -Here are a few samples: - -* stub:smtp://somehost.foo.com?user=whatnot&something=else -* -stub:http://somehost.bar.com/something[http://somehost.bar.com/something] +Here are a few samples of stubbing endpoint uris -=== See Also +[source] +---- +stub:smtp://somehost.foo.com?user=whatnot&something=else +stub:http://somehost.bar.com/something +---- -* link:configuring-camel.html[Configuring Camel] -* link:component.html[Component] -* link:endpoint.html[Endpoint] -* link:getting-started.html[Getting Started] http://git-wip-us.apache.org/repos/asf/camel/blob/2cc68570/camel-core/src/main/docs/test-component.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/test-component.adoc b/camel-core/src/main/docs/test-component.adoc index ff7b07a..395d469 100644 --- a/camel-core/src/main/docs/test-component.adoc +++ b/camel-core/src/main/docs/test-component.adoc @@ -27,24 +27,24 @@ Maven users will need to add the following dependency to their `pom.xml` for this component when using *Camel 2.8* or older: [source,xml] ------------------------------------------------------------- +---- <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-spring</artifactId> <version>x.x.x</version> <!-- use the same version as your Camel core version --> </dependency> ------------------------------------------------------------- +---- From Camel 2.9 onwards the link:test.html[Test] component is provided directly in the camel-core. === URI format -[source,java] --------------------------------- +[source] +---- test:expectedMessagesEndpointUri --------------------------------- +---- Where *expectedMessagesEndpointUri* refers to some other link:component.html[Component] URI that the expected message bodies are @@ -102,10 +102,10 @@ with the following path and query parameters: For example, you could write a test case as follows: [source,java] --------------------------------------------------- +---- from("seda:someEndpoint"). to("test:file://data/expectedOutput?noop=true"); --------------------------------------------------- +---- If your test then invokes the http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/component/mock/MockEndpoint.html#assertIsSatisfied(org.apache.camel.CamelContext)[MockEndpoint.assertIsSatisfied(camelContext) @@ -116,9 +116,4 @@ link:mock.html[Mock] component. === See Also -* link:configuring-camel.html[Configuring Camel] -* link:component.html[Component] -* link:endpoint.html[Endpoint] -* link:getting-started.html[Getting Started] - * link:spring-testing.html[Spring Testing] http://git-wip-us.apache.org/repos/asf/camel/blob/2cc68570/camel-core/src/main/docs/timer-component.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/timer-component.adoc b/camel-core/src/main/docs/timer-component.adoc index e1e04ac..a3d0220 100644 --- a/camel-core/src/main/docs/timer-component.adoc +++ b/camel-core/src/main/docs/timer-component.adoc @@ -7,10 +7,10 @@ timer fires You can only consume events from this endpoint. === URI format -[source,java] --------------------- +[source] +---- timer:name[?options] --------------------- +---- Where `name` is the name of the `Timer` object, which is created and shared across endpoints. So if you use the same name for all your timer @@ -83,7 +83,7 @@ When the timer is fired, it adds the following information as properties to the `Exchange`: [width="100%",cols="10%,10%,80%",options="header",] -|======================================================================= +|=== |Name |Type |Description |`Exchange.TIMER_NAME` |`String` |The value of the `name` option. @@ -95,18 +95,18 @@ to the `Exchange`: |`Exchange.TIMER_FIRED_TIME` |`Date` |The time when the consumer fired. |`Exchange.TIMER_COUNTER` |`Long` |*Camel 2.8:* The current fire counter. Starts from 1. -|======================================================================= +|=== === Sample To set up a route that generates an event every 60 seconds: [source,java] -------------------------------------------------------------------------------------------- - from("timer://foo?fixedRate=true&period=60000").to("bean:myBean?method=someMethodName"); -------------------------------------------------------------------------------------------- +---- +from("timer://foo?fixedRate=true&period=60000").to("bean:myBean?method=someMethodName"); +---- -TIP:Instead of 60000 you can use period=60s which is more friendly to read. +TIP: Instead of 60000 you can use period=60s which is more friendly to read. The above route will generate an event and then invoke the `someMethodName` method on the bean called `myBean` in the @@ -115,27 +115,27 @@ link:registry.html[Registry] such as JNDI or link:spring.html[Spring]. And the route in Spring DSL: [source,xml] -------------------------------------------------------------- - <route> - <from uri="timer://foo?fixedRate=true&period=60000"/> - <to uri="bean:myBean?method=someMethodName"/> - </route> -------------------------------------------------------------- +----- +<route> + <from uri="timer://foo?fixedRate=true&period=60000"/> + <to uri="bean:myBean?method=someMethodName"/> +</route> +----- -#=== Firing as soon as possible +=== Firing as soon as possible -#=== Available as of Camel 2.17 +*Available as of Camel 2.17* You may want to fire messages in a Camel route as soon as possible you can use a negative delay: [source,xml] -------------------------------------------------- - <route> - <from uri="timer://foo?delay=-1"/> - <to uri="bean:myBean?method=someMethodName"/> - </route> -------------------------------------------------- +---- +<route> + <from uri="timer://foo?delay=-1"/> + <to uri="bean:myBean?method=someMethodName"/> +</route> +---- In this way the timer will fire messages immediately. @@ -146,7 +146,7 @@ reached. If you don't specify a repeatCount then the timer will continue firing messages until the route will be stopped. -#=== Firing only once +=== Firing only once *Available as of Camel 2.8* @@ -154,18 +154,14 @@ You may want to fire a message in a Camel route only once, such as when starting the route. To do that you use the repeatCount option as shown: [source,xml] -------------------------------------------------- - <route> - <from uri="timer://foo?repeatCount=1"/> - <to uri="bean:myBean?method=someMethodName"/> - </route> -------------------------------------------------- +---- +<route> + <from uri="timer://foo?repeatCount=1"/> + <to uri="bean:myBean?method=someMethodName"/> +</route> +---- === See Also -* link:configuring-camel.html[Configuring Camel] -* link:component.html[Component] -* link:endpoint.html[Endpoint] -* link:getting-started.html[Getting Started] - +* link:scheduler.html[Scheduler] * link:quartz.html[Quartz] http://git-wip-us.apache.org/repos/asf/camel/blob/2cc68570/camel-core/src/main/docs/transformer.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/transformer.adoc b/camel-core/src/main/docs/transformer.adoc index ee03a70..de17054 100644 --- a/camel-core/src/main/docs/transformer.adoc +++ b/camel-core/src/main/docs/transformer.adoc @@ -1,6 +1,5 @@ [[Transformer-Transformer]] -Transformer -^^^^^^^^^^^^ +== Transformer *Available as of Camel 2.19* @@ -18,12 +17,11 @@ type and apply. Once transform succeed or message is already in expected type, t [[Transformer-DataTypeFormat]] -Data type format -^^^^^^^^^^^^^^^ -[source,java] ---------------------------------------------- +=== Data type format +[source] +---- scheme:name ---------------------------------------------- +---- where *scheme* is the type of data model like `java`, `xml` or `json`, and *name* is the individual data type name. If you only specify *scheme* then it hits all the data types which has that scheme like a wildcard. @@ -31,10 +29,9 @@ a wildcard. [[Transformer-SupportedTransformers]] -Supported Transformers -^^^^^^^^^^^^^^^^^^^^^ +=== Supported Transformers -|======================================================================= +|=== | Transformer | Description | Data Format Transformer | Transform with using link:data-format.html[Data Format] @@ -42,15 +39,14 @@ Supported Transformers | Endpoint Transformer | Transform with using link:endpoint.html[Endpoint] | Custom Transformer | Transform with using custom transformer class. Transformer must be a subclass of `org.apache.camel.spi.Transformer` -|======================================================================= +|=== [[Transformer-CommonOptions]] -Common Options -^^^^^^^^^^^^^ +==== Common Options All transformers have following common options to specify which data type is supported by the transformer. `scheme` or both of `fromType` and `toType` must be specified. -|======================================================================= +|=== | Name | Description | scheme | Type of data model like `xml` or `json`. For example if `xml` is specified, the transformer is applied for all java -> xml and xml -> java transformation. @@ -58,25 +54,25 @@ All transformers have following common options to specify which data type is sup | fromType | <<Transformer-DataTypeFormat,Data type>> to transform from. | toType | <<Transformer-DataTypeFormat,Data type>> to transform to. -|======================================================================= +|=== [[Transformer-DataFormat]] -DataFormat Transformer Options -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -|======================================================================= +==== DataFormat Transformer Options +|=== | Name | Description | type | link:data-format.html[Data Format] type | ref | reference to the link:data-format.html[Data Format] ID -|======================================================================= +|=== + Here is an example to specify bindy DataFormat type: Java DSL: [source,java] -------------------------------------------------------------------- +---- BindyDataFormat bindy = new BindyDataFormat(); bindy.setType(BindyType.Csv); bindy.setClassType(com.example.Order.class); @@ -84,77 +80,75 @@ transformer() .fromType(com.example.Order.class) .toType("csv:CSVOrder") .withDataFormat(bindy); -------------------------------------------------------------------- +---- XML DSL: [source,xml] -------------------------------------------------------------------- +---- <dataFormatTransformer fromType="java:com.example.Order" toType="csv:CSVOrder"> <bindy id="csvdf" type="Csv" classType="com.example.Order"/> </dataFormatTransformer> -------------------------------------------------------------------- - +---- [[Transformer-Endpoint]] -Endpoint Transformer Options -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -|======================================================================= +=== Endpoint Transformer Options +|=== | Name | Description | ref | Reference to the link:endpoint.html[Endpoint] ID | uri | link:endpoint.html[Endpoint] URI -|======================================================================= +|=== + Here is an example to specify endpoint URI in Java DSL: + [source,java] -------------------------------------------------------------------- +---- transformer() .fromType("xml") .toType("json") .withUri("dozer:myDozer?mappingFile=myMapping.xml..."); -------------------------------------------------------------------- +---- And here is an example to specify endpoint ref in XML DSL: [source,xml] -------------------------------------------------------------------- +---- <endpointTransformer ref="myDozerEndpoint" fromType="xml" toType="json"/> -------------------------------------------------------------------- - - +---- [[Transformer-Custom]] -Custom Transformer Options -^^^^^^^^^^^^^^^^^^^^^^^^^^^ +=== Custom Transformer Options Note that Transformer must be a subclass of `org.apache.camel.spi.Transformer` -|======================================================================= +|=== | Name | Description | ref | Reference to the custom Transformer bean ID | className | Fully qualified class name of the custom Transformer class -|======================================================================= +|=== + Here is an example to specify custom Transformer class: + Java DSL: [source,java] -------------------------------------------------------------------- +---- transformer() .fromType("xml") .toType("json") .withJava(com.example.MyCustomTransformer.class); -------------------------------------------------------------------- +---- XML DSL: [source,xml] -------------------------------------------------------------------- +---- <customTransformer className="com.example.MyCustomTransformer" fromType="xml" toType="json"/> -------------------------------------------------------------------- +---- [[Transformer-Examples]] -Examples -^^^^^^^ +=== Examples For example to declare the Endpoint Transformer which uses xslt component to transform from `xml:ABCOrder` to `xml:XYZOrder`, we can do as follows: @@ -196,7 +190,6 @@ XML DSL: [source,xml] ------------------------------------------------------------------- <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> - .... <route> <from uri="direct:abc"/> <inputType urn="xml:ABCOrder"/> http://git-wip-us.apache.org/repos/asf/camel/blob/2cc68570/camel-core/src/main/docs/validator-component.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/validator-component.adoc b/camel-core/src/main/docs/validator-component.adoc index 7285591..60a0048 100644 --- a/camel-core/src/main/docs/validator-component.adoc +++ b/camel-core/src/main/docs/validator-component.adoc @@ -19,10 +19,10 @@ http://relaxng.org/[RelaxNG XML Syntax]. === URI format -[source,java] ------------------------------------ +[source] +---- validator:someLocalOrRemoteResource ------------------------------------ +---- Where *someLocalOrRemoteResource* is some URL to a local resource on the classpath or a full URL to a remote resource or resource on the file @@ -37,14 +37,14 @@ Maven users will need to add the following dependency to their `pom.xml` for this component when using *Camel 2.8* or older: [source,xml] ------------------------------------------------------------- +---- <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-spring</artifactId> <version>x.x.x</version> <!-- use the same version as your Camel core version --> </dependency> ------------------------------------------------------------- +---- From Camel 2.9 onwards the link:validation.html[Validation] component is provided directly in the camel-core. @@ -119,9 +119,3 @@ the JMX operation `clearCachedSchema. `You can also use this method to programmatically clear the cache. This method is available on the `ValidatorEndpoint `class`.` -=== See Also - -* link:configuring-camel.html[Configuring Camel] -* link:component.html[Component] -* link:endpoint.html[Endpoint] -* link:getting-started.html[Getting Started] http://git-wip-us.apache.org/repos/asf/camel/blob/2cc68570/camel-core/src/main/docs/validator.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/validator.adoc b/camel-core/src/main/docs/validator.adoc index 477bdcd..443c8e5 100644 --- a/camel-core/src/main/docs/validator.adoc +++ b/camel-core/src/main/docs/validator.adoc @@ -1,6 +1,5 @@ [[Validator-Validator]] -Validator -^^^^^^^^^^ +== Validator *Available as of Camel 2.19* @@ -14,22 +13,20 @@ camel internal processor looks for a corresponding Validator from the registry a [[Validator-DataTypeFormat]] -Data type format -^^^^^^^^^^^^^^^ -[source,java] ---------------------------------------------- +=== Data type format + +[source] +---- scheme:name ---------------------------------------------- +---- + where *scheme* is the type of data model like `java`, `xml` or `json`, and *name* is the individual data type name. - - [[Validator-SupportedValidators]] -Supported Validators -^^^^^^^^^^^^^^^^^^^^^ +=== Supported Validators -|======================================================================= +|=== | Validator | Description | Predicate Validator | Validate with using link:expression.html[Expression] or link:predicate.html[Predicate] @@ -37,135 +34,132 @@ Supported Validators | Endpoint Transformer | Validate by forwarding to the link:endpoint.html[Endpoint] to be used with validation component such as link:validator-component.adoc[Validation Component] or link:bean-validation.html[Bean Validation Component]. | Custom Transformer | Validate with using custom validator class. Validator must be a subclass of `org.apache.camel.spi.Validator` -|======================================================================= +|=== [[Validator-CommonOptions]] -Common Options -^^^^^^^^^^^^^ +=== Common Options All validators have following common options to specify which data type is supported by the validator. `type` must be specified. -|======================================================================= +|=== | Name | Description | type | <<Validator-DataTypeFormat,Data type>> to validate. -|======================================================================= +|=== [[Validator-Predicate]] -Predicate Validator Options -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +=== Predicate Validator Options -|======================================================================= +|=== | Name | Description | expression | link:expression.html[Expression] or link:predicate.html[Predicate] to be used for validation -|======================================================================= +|=== + Here is an example to specify a validation predicate: Java DSL: [source,java] -------------------------------------------------------------------- +---- validator() .type("csv:CSVOrder") .withExpression(bodyAs(String.class).contains("{name:XOrder}")); -------------------------------------------------------------------- +---- XML DSL: [source,xml] -------------------------------------------------------------------- +---- <predicateValidator Type="csv:CSVOrder"> <simple>${body} contains '{name:XOrder'</simple> </predicateValidator> -------------------------------------------------------------------- - +---- [[Validator-Endpoint]] -Endpoint Validator Options -^^^^^^^^^^^^^^^^^^^^^^^^^^^ +=== Endpoint Validator Options -|======================================================================= +|=== | Name | Description | ref | Reference to the link:endpoint.html[Endpoint] ID | uri | link:endpoint.html[Endpoint] URI -|======================================================================= +|=== + Here is an example to specify endpoint URI in Java DSL: [source,java] -------------------------------------------------------------------- +---- validator() .type("xml") .withUri("validator:xsd/schema.xsd"); -------------------------------------------------------------------- +---- And here is an example to specify endpoint ref in XML DSL: [source,xml] -------------------------------------------------------------------- +---- <endpointValidator uri="validator:xsd/schema.xsd" type="xml"/> -------------------------------------------------------------------- +---- + Note that the Endpoint Validator just forwards the message to the specified endpoint. In above example, camel forwards the message to the `validator:` endpoint, which actually is a link:validator-component.adoc[Validation Component]. You can also use any other validation component like link:bean-validation.html[Bean Validation Component]. [[Validator-Custom]] -Custom Validator Options -^^^^^^^^^^^^^^^^^^^^^^^^^ +=== Custom Validator Options Note that Validator must be a subclass of `org.apache.camel.spi.Validator` -|======================================================================= +|=== | Name | Description | ref | Reference to the custom Validator bean ID | className | Fully qualified class name of the custom Validator class -|======================================================================= +|=== + Here is an example to specify custom Validator class: Java DSL: [source,java] -------------------------------------------------------------------- +---- validator() .type("json") .withJava(com.example.MyCustomValidator.class); -------------------------------------------------------------------- +---- XML DSL: [source,xml] -------------------------------------------------------------------- +---- <customTransformer className="com.example.MyCustomValidator" type="json"/> -------------------------------------------------------------------- +---- [[Validator-Examples]] -Examples -^^^^^^^ +=== Examples For example to declare the Endpoint Validator which uses validator component to validate `xml:ABCOrder`, we can do as follows: Java DSL: [source,java] -------------------------------------------------------------------- +---- validator() .type("xml:ABCOrder") .withUri("validator:xsd/schema.xsd"); -------------------------------------------------------------------- +---- XML DSL: [source,xml] -------------------------------------------------------------------- +---- <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> <validators> <endpointValidator uri="validator:xsd/schema.xsd" type="xml:ABCOrder"/> </validators> - .... </camelContext> -------------------------------------------------------------------- +---- If you have following route definition, above validator will be applied when `direct:abc` endpoint receives the message. Note that `inputTypeWithValidate` is used instead of `inputType` in Java DSL, @@ -173,21 +167,20 @@ and the `validate` attribute on the inputType declaration is set to `true` in XM Java DSL: [source,java] -------------------------------------------------------------------- +---- from("direct:abc") .inputTypeWithValidate("xml:ABCOrder") .log("${body}"); -------------------------------------------------------------------- +---- XML DSL: [source,xml] -------------------------------------------------------------------- +---- <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> - .... <route> <from uri="direct:abc"/> <inputType urn="xml:ABCOrder" validate="true"/> <log message="${body}"/> </route> </camelContext> -------------------------------------------------------------------- +---- http://git-wip-us.apache.org/repos/asf/camel/blob/2cc68570/camel-core/src/main/docs/vm-component.adoc ---------------------------------------------------------------------- diff --git a/camel-core/src/main/docs/vm-component.adoc b/camel-core/src/main/docs/vm-component.adoc index d81844e..ee3525a 100644 --- a/camel-core/src/main/docs/vm-component.adoc +++ b/camel-core/src/main/docs/vm-component.adoc @@ -17,10 +17,10 @@ VM is an extension to the link:seda.html[Seda] component. === URI format -[source,java] ----------------------- +[source] +---- vm:queueName[?options] ----------------------- +---- Where *`queueName`* can be any string to uniquely identify the endpoint within the JVM (or at least within the classloader that loaded @@ -29,20 +29,17 @@ camel-core.jar) You can append query options to the URI in the following format: `?option=value&option=value&...` -*Before Camel 2.3 - Same URI must be used for both producer and -consumer* - An exactly identical link:vm.html[VM] endpoint URI *must* be used for both the producer and the consumer endpoint. Otherwise, Camel will create a second link:vm.html[VM] endpoint despite that the `queueName` portion of the URI is identical. For example: [source,java] ---------------------------------------------------------- +---- from("direct:foo").to("vm:bar?concurrentConsumers=5"); from("vm:bar?concurrentConsumers=5").to("file://output"); ---------------------------------------------------------- +---- Notice that we have to use the full URI, including options in both the producer and consumer. @@ -52,11 +49,11 @@ Using the queue name `bar`, we could rewrite the previous exmple as follows: [source,java] ---------------------------------------------------------- +---- from("direct:foo").to("vm:bar"); from("vm:bar?concurrentConsumers=5").to("file://output"); ---------------------------------------------------------- +---- === Options @@ -127,22 +124,18 @@ In the route below we send exchanges across CamelContext instances to a VM queue named `order.email`: [source,java] ---------------------------------------------------------------- +---- from("direct:in").bean(MyOrderBean.class).to("vm:order.email"); ---------------------------------------------------------------- +---- And then we receive exchanges in some other Camel context (such as deployed in another `.war` application): [source,java] ------------------------------------------------------- +---- from("vm:order.email").bean(MyOrderEmailSender.class); ------------------------------------------------------- +---- === See Also -* link:configuring-camel.html[Configuring Camel] -* link:component.html[Component] -* link:endpoint.html[Endpoint] -* link:getting-started.html[Getting Started] * link:seda.html[Seda]