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 0c5b620c3cf Polished 0c5b620c3cf is described below commit 0c5b620c3cfeb3881a7ab1ebfab6758faa63a1ca Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Tue Feb 13 13:54:39 2024 +0100 Polished --- docs/user-manual/modules/ROOT/pages/variables.adoc | 32 ++++++++++------------ 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/docs/user-manual/modules/ROOT/pages/variables.adoc b/docs/user-manual/modules/ROOT/pages/variables.adoc index 9c3dc1a9a38..084adc21b69 100644 --- a/docs/user-manual/modules/ROOT/pages/variables.adoc +++ b/docs/user-manual/modules/ROOT/pages/variables.adoc @@ -4,10 +4,9 @@ In Camel 4.4, we have introduced the concept of _variables_. -A variable is a key/value that can hold a value that can either be private per `Exchange` or global shared -in the `CamelContext`. +A variable is a key/value that can hold a value that can either be private per `Exchange`, or shared per route, or globally. -NOTE: You can also use _exchange properties_ as variables but the exchange properties are also used internally by Camel, +NOTE: You can also use _exchange properties_ as variables, but the exchange properties are also used internally by Camel, and some EIPs and components. With the newly introduced _variables_ then these are exclusively for end users. == Variable Repository @@ -22,8 +21,8 @@ The `ExchangeVariableRepository` is special as its private per exchange and is t The `RouteVariableRepository` is a single repository that holds variables that are route scoped. TIP: There is also `org.apache.camel.spi.BrowsableVariableRepository` which is an extension to `VariableRepository` that -has APIs to browse the currently variables. This is used by Camel with Camel JBang, and JMX to be able to see the current variables -from management tooling, CLI and the developer console. +has APIs to browse the current variables. Camel uses this with Camel JBang, and JMX to be able to see the current variables +from management tooling, CLI, and the developer console. === Custom variable repositories @@ -98,9 +97,9 @@ String str = context.getVariable("route:myRouteId:myRouteKey", String.class); It is also possible to use variables in Camel xref:routes.adoc[routes] using the setVariable, removeVariable, and convertVariableTo EIPs. -These EIPs makes it possible to set and remove variables from routes. And you can also access variables from the xref:components:languages:simple-language.adoc[Simple] language. +These EIPs make it possible to set and remove variables from routes. And you can also access variables from the xref:components:languages:simple-language.adoc[Simple] language. -In the following route we set a variable on the exchange which we use later to build a human-readable event message: +In the following route, we set a variable on the exchange which we use later to build a human-readable event message: [tabs] ==== @@ -159,8 +158,8 @@ YAML:: ==== When `route` variables in Camel routes, then the `routeId` is implied as the current route, if not explicit declared. -For example the following example the first route will set a variable in the 2nd route. And then 2nd route can then get -the route variable without having to specify the route id: +For example, the following example the first route will set a variable (`route:second:foo`) in the second route. +Then the second route can get hold of the variable without having to specify its route id `route:foo`: [tabs] ==== @@ -205,8 +204,8 @@ camel.variable.random = 999 Here the gold variable is set on the `route` repository, and the other variables are set on the `global` repository. -The value of a variable can also be loaded from file system, such as a JSon file. To do this you should -prefix the value with `resource:file:` or `resource:classpath:` to load from file system or classpath, +The value of a variable can also be loaded from the file system, such as a JSon file. To do this, you should +prefix the value with `resource:file:` or `resource:classpath:` to load from the file system or classpath, as shown below: [source,properties] @@ -234,10 +233,10 @@ or with the xref:components:eips:claimCheck-eip.adoc[Claim Check] EIP. === Important concept when using variables and EIPs -It is **important** to understand that the variables focuses the use of the message **body** only. +It is **important** to understand that the variables focus the use of the message **body** only. This is on purpose to keep it simpler and primary work with the message body as the user data. -The following table summarises what the EIP supports with variables: +The following table summarizes what the EIP supports with variables: |=== |*EIP* | *VariableSend* | *VariableReceive* @@ -254,7 +253,7 @@ The following table summarises what the EIP supports with variables: The EIPs listed above have support for using variables when sending and receiving data. This is done by using the `variableSend` and `variableReceive` options to specify the name of the variable. -The EIPs works in two modes where *variableSend* and *variableReceive* is a little bit different, so pay attention to the following table: +The EIPs works in two modes where *variableSend* and *variableReceive* are a little bit different, so pay attention to the following table: |=== | *VariableSend* | *VariableReceive* @@ -263,11 +262,11 @@ The EIPs works in two modes where *variableSend* and *variableReceive* is a litt |=== The *VariableSend* is intended for sending as regular Camel where the sending headers are from the current `Message` and the body is -from the variable. In other words it's only the message body that is taken from the variable instead of the current `Message` body. +from the variable. In other words it's only the message body taken from the variable instead of the current `Message` body. The *VariableReceive* works in a different mode. The idea is that all the received data is stored as variables. This means the current `Message` is not changed at all. The received body is stored in the variable, and the received headers (transport headers etc.) are stored as read-only -headers as variables as well. The names of the variable is `header:variableName.headerName`. For example if the variable is `myVar` and the header is `Content-Type` +headers as variables as well. The names of the variable is `header:variableName.headerName`. For example, if the variable is `myVar` and the header is `Content-Type` then the header is stored as a variable with the full name `header:myVar.Content-Type`. === Example using VariableReceive @@ -439,4 +438,3 @@ from: NOTE: In the examples above the transform `Bye $\{body}` will result as `Bye ` because the `Message` has no message body, as the incoming message body is stored in the variable `myKey` instead. -