This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new 1672fbd Polish and cleanup documentation 1672fbd is described below commit 1672fbdd9b499979614f5bfa257d018f360a26e8 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Wed Aug 11 17:11:44 2021 +0200 Polish and cleanup documentation --- docs/user-manual/modules/ROOT/pages/processor.adoc | 2 + .../modules/ROOT/pages/producertemplate.adoc | 45 ++++++++++++---------- .../modules/ROOT/pages/property-binding.adoc | 2 +- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/docs/user-manual/modules/ROOT/pages/processor.adoc b/docs/user-manual/modules/ROOT/pages/processor.adoc index 184b787..147b4af 100644 --- a/docs/user-manual/modules/ROOT/pages/processor.adoc +++ b/docs/user-manual/modules/ROOT/pages/processor.adoc @@ -80,6 +80,8 @@ This also works in Java DSL: from("activemq:myQueue").process("#class:com.acme.MyProcessor"); ---- +NOTE: For more details about the `#class:` prefix (and others) then see xref:property-binding.adoc[Property Binding]. + However in Java DSL you would often use the type safe way and provide the class type directly as previously shown: [source,java] diff --git a/docs/user-manual/modules/ROOT/pages/producertemplate.adoc b/docs/user-manual/modules/ROOT/pages/producertemplate.adoc index 8de11d0..2ded9c4 100644 --- a/docs/user-manual/modules/ROOT/pages/producertemplate.adoc +++ b/docs/user-manual/modules/ROOT/pages/producertemplate.adoc @@ -1,7 +1,7 @@ [[ProducerTemplate-ProducerTemplate]] = ProducerTemplate -The ProducerTemplate interface allows you to send message exchanges to +The `ProducerTemplate` interface allows you to send message exchanges to endpoints in a variety of different ways to make it easy to work with Camel xref:endpoint.adoc[Endpoint] instances from Java code. @@ -10,7 +10,7 @@ lots of messages to the same endpoint; or you can specify an xref:endpoint.adoc[Endpoint] or uri as the first parameter. The `sendBody()` method allows you to send any object to an endpoint -easily. +easily as shown: [source,java] ---- @@ -30,40 +30,39 @@ template.sendBodyAndHeader("activemq:MyQueue", You can also supply an `Exchange` or a `Processor` to customize the exchange. +== Send vs Request methods -[[ProducerTemplate-requestmethods]] -== `request*()` methods +The `ProducerTemplate` supports xref:exchange-pattern.adoc[Message Exchange Patterns] (MEP) +that are used to control the messaging style to use: -The `send*()` methods use the default Message Exchange Pattern (InOnly, -InOut etc) as the endpoint. If you want to explicitly perform a -request/response (InOut) you can use the `request*()` methods instead of -the `send*()` methods. +* _send methods_ - xref:{eip-vc}:eips:event-message.adoc[Event Message] (InOnly) +* _request methods_ - xref:{eip-vc}:eips:requestReply-eip.adoc[Request Reply] (InOut) -E.g. let's invoke an endpoint and get the response: +In other words, all the methods on the `ProducerTemplate` that starts with `sendXXX` are for InOnly messaging, +and all the methods starting with `requestXXX` are for InOut messaging. + +Lets see an example where we invoke an endpoint to get the response (InOut): [source,java] ---- Object response = template.requestBody("<hello/>"); -// you can cast the response directly +// you can type convert the response to what you want such as String String ret = template.requestBody("<hello/>", String.class); -// or specify the endpoint directly +// or specify the endpoint uri in the method String ret = template.requestBody("cxf:bean:HelloWorldService", "<hello/>", String.class); ---- - -[[ProducerTemplate-Fluentinterface]] == Fluent interface -*Since Camel 2.18.0* +The `FluentProducerTemplate` provides a fluent syntax over the regular `ProducerTemplate`. -The FluentProducerTemplate provides a fluent syntax to -ProducerTemplate. +Here are some examples: -Examples: +=== Set headers and body -*Set headers and body* +This is the most common style with fluent builders to set headers, and message body as show: [source,java] ---- @@ -75,7 +74,9 @@ Integer result = FluentProducerTemplate.on(context) .request(Integer.class); ---- -*Use a processor* +=== Using a processor + +Here we use xref:processor.adoc[Processor] to prepare the message to be sent. [source,java] ---- @@ -85,7 +86,10 @@ Integer result = FluentProducerTemplate.on(context) .request(Integer.class); ---- -*Customize template* +=== Advanced with a template customizer + +This is rarely in use, but a `TemplateCustomizer` can be used for advanced use-cases +to control various aspects of the `FluentProducerTemplate` such as configuring to use a custom thread pool: [source,java] ---- @@ -99,5 +103,4 @@ Object result = FluentProducerTemplate.on(context) .withBody("the body") .to("direct:start") .request(); - ---- diff --git a/docs/user-manual/modules/ROOT/pages/property-binding.adoc b/docs/user-manual/modules/ROOT/pages/property-binding.adoc index 02f87da..6f44c86 100644 --- a/docs/user-manual/modules/ROOT/pages/property-binding.adoc +++ b/docs/user-manual/modules/ROOT/pages/property-binding.adoc @@ -2,7 +2,7 @@ = Property binding in Camel Camel supports binding property values (key=value) in many places such as configuration of Camel -components, endpoints, EIPs, and Camel bootstrap configuration. +components, endpoints, EIPs, routes, and Camel bootstrap configuration. Together with property placeholders, property placeholder functions, then there is plenty of power, but also something that takes a little learning to master.