[ 
https://issues.apache.org/jira/browse/CAMEL-19749?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17796363#comment-17796363
 ] 

Raymond commented on CAMEL-19749:
---------------------------------

As part of the refinement, I can share my experience with vars. Our Camel based 
system uses three kind of types:

1. Headers
2. Properties
3. Variables
 
Functional explanation can be found here: 
[https://academy.dovetail.world/docs/guides/references/using_variables_in_dovetail]

Technical explanation:

1. Headers: We use Camel headers to set metadata (or sometimes the whole body) 
on the exchange/message to use later within the route. Sometimes we use message 
properties as these are not sent to external systems (for example by the HTTP 
components).
2. Properties: In our case, properties are static variables that are evaluated 
before we create the Camel route. They are final and can't be changed during 
runtime of the route.
3. Variables.  We also have the concept “variables” those are data values that 
can be used independently of the exchange/camelcontext. These are so-called 
global variables (we also call them tenant variables). In our case, these 
variables are stored within MongoDB. This means route A can set a variable and 
route B can use that variable, or route A sets the variables on a condition and 
the next exchange uses the variable that already is set. Variables are mutable 
and global on our system.

Based on our concepts, within Camel you can think of the following aspects:

1. Scope: (message, route, routeGroup, camelcontext)
2. Store: (memory, cache, database)
3. Immutability: (Can a variable be changed after initialization, or is it 
final?)
4. Data type: In our case we always use text (String object) for variables, but 
Camel may use different data types.
5. Visibility (Access Modifiers): Maybe you can set the scope with help of 
modifiers (is it private or public)?

The syntax in the Camel DSL and Simple language were already mentioned.

Hope this gave some feedback on how we are currently use variables together 
with Camel.






 

 

 

> camel-core - Allow users to use variables in route to store data instead of 
> headers
> -----------------------------------------------------------------------------------
>
>                 Key: CAMEL-19749
>                 URL: https://issues.apache.org/jira/browse/CAMEL-19749
>             Project: Camel
>          Issue Type: New Feature
>          Components: camel-core, eip
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>            Priority: Major
>             Fix For: 4.4.0
>
>
> Users that need to do message transformation in Camel routes may find 
> themselves having to store data in headers / claim-check / exchange 
> properties from multiple sources before they have all data needed to build a 
> response message.
> Today users are doing this in different ways.
> However we may want to introduce variables that users can name and store the 
> data, then they can do this more intuitive, like they would do in a 
> programming language.
> {code}
> from(kafka("topic1").setVar("customer"))
>    .to("sql:get-order-by-cust?id=${var.customer.id}").setVar("order")
>     .transform().simple( ' Thank you ${var.customer.name} for ordering 
> ${var.order.item}'))
> {code}
> Then you have 2 variables
> - customer
> - order
> Then the variable customer can be used anywhere in Camel like it was a header 
> with ${header.xxx} but with ${var.customer} in the simple language etc.
> This proposal needs some more though and design/prototype.
> But this should be done in a way that does not affect regular Camel DSL as it 
> is, but with variables then results during routing that usually will be 
> override current message body / headers, are stored in variables, that the 
> user assign a name and therefore better can understand what the data the 
> variable contains are.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to