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 3b66468d0a07 chore: camel-jbang - sync the bundled examples: values 
for the route kept in variables, not headers (#28508)
3b66468d0a07 is described below

commit 3b66468d0a071239b2f17539132a098a02ef9080
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Oct 26 10:50:54 2026 +0100

    chore: camel-jbang - sync the bundled examples: values for the route kept 
in variables, not headers (#28508)
    
    Synced with mvn -Psync-example-catalog generate-resources from 
camel-jbang-examples main (#130): order-generator, json-transform, csv-to-json, 
order-lines, aggregator and enrich-and-dedupe keep a value only the route uses 
in a variable instead of a header, which is sent on with the message to the 
next endpoint.
    
    Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
---
 .../main/resources/examples/camel-jbang-example-catalog.json | 12 ++++++------
 .../src/main/resources/examples/route/aggregator/README.md   |  6 +++---
 .../examples/route/aggregator/aggregator.camel.yaml          |  8 ++++----
 .../resources/examples/route/enrich-and-dedupe/README.md     |  4 ++--
 .../route/enrich-and-dedupe/enrich-and-dedupe.camel.yaml     | 10 +++++-----
 .../src/main/resources/examples/route/order-lines/README.md  |  9 +++++----
 .../examples/route/order-lines/order-lines.camel.yaml        | 10 +++++-----
 .../main/resources/examples/run/order-generator/README.md    |  8 ++++----
 .../examples/run/order-generator/order-generator.camel.yaml  |  6 +++---
 .../main/resources/examples/transform/csv-to-json/README.md  |  2 +-
 .../examples/transform/csv-to-json/csv-to-json.camel.yaml    |  6 +++---
 .../resources/examples/transform/json-transform/README.md    |  5 +++--
 .../transform/json-transform/json-transform.camel.yaml       |  6 +++---
 13 files changed, 47 insertions(+), 45 deletions(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/camel-jbang-example-catalog.json
 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/camel-jbang-example-catalog.json
index f4e34cb639de..261b2913b92d 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/camel-jbang-example-catalog.json
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/camel-jbang-example-catalog.json
@@ -1135,7 +1135,7 @@
             "eips": [
                 "aggregate",
                 "split",
-                "setHeader",
+                "setVariable",
                 "marshal",
                 "unmarshal"
             ],
@@ -1352,7 +1352,7 @@
     {
         "name": "route/order-lines",
         "title": "Order lines",
-        "description": "Each order read from the orders directory is split 
into one message per line, the order id travels along in a header, and the log 
shows the order, one pick line per line, and the parent's confirmation that all 
lines went to picking.",
+        "description": "Each order read from the orders directory is split 
into one message per line, the order id travels along in a variable, and the 
log shows the order, one pick line per line, and the parent's confirmation that 
all lines went to picking.",
         "level": "route",
         "teaches": {
             "components": [
@@ -1361,7 +1361,7 @@
             ],
             "eips": [
                 "split",
-                "setHeader",
+                "setVariable",
                 "unmarshal"
             ],
             "languages": [
@@ -1433,7 +1433,7 @@
                 "log"
             ],
             "eips": [
-                "setHeader",
+                "setVariable",
                 "setBody"
             ],
             "languages": [
@@ -1712,7 +1712,7 @@
     {
         "name": "transform/json-transform",
         "title": "JSON transform",
-        "description": "The shop's order in order.json is reshaped for the 
warehouse: jsonpath reads the order id and the number of lines into headers, jq 
builds the pick list with only sku and quantity per line, and both the order 
and the pick list are logged.",
+        "description": "The shop's order in order.json is reshaped for the 
warehouse: jsonpath reads the order id and the number of lines into variables, 
jq builds the pick list with only sku and quantity per line, and both the order 
and the pick list are logged.",
         "level": "transform",
         "teaches": {
             "components": [
@@ -1721,7 +1721,7 @@
             ],
             "eips": [
                 "transform",
-                "setHeader",
+                "setVariable",
                 "setBody"
             ],
             "languages": [
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/route/aggregator/README.md
 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/route/aggregator/README.md
index 56789ff9d1e1..c1cd66deb716 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/route/aggregator/README.md
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/route/aggregator/README.md
@@ -31,9 +31,9 @@ can be repeated.
 
 ## How it works
 
-- The first route reads the orders, keeps the order id in a header, splits 
them into lines, and sends every
+- The first route reads the orders, keeps the order id in a variable, splits 
them into lines, and sends every
   line to `direct:shipment`, as a warehouse system would report picks one by 
one.
-- The second route aggregates: `correlationExpression` `${header.orderId}` 
groups lines of the same order,
+- The second route aggregates: `correlationExpression` `${variable.orderId}` 
groups lines of the same order,
   `completionSizeExpression` `${header.CamelSplitSize}` says how many lines 
make the order complete, and the
   `GroupedBodyAggregationStrategy` collects the bodies into a list.
 - When a shipment completes, the list of lines is written as JSON with 
`marshal` and logged.
@@ -41,7 +41,7 @@ can be repeated.
 ## Build it step by step
 
 1. Start from `order-lines` and send each line to `direct:shipment` instead of 
only logging it.
-2. Add a route from `direct:shipment` with an `aggregate` correlating on 
`${header.orderId}` and a fixed
+2. Add a route from `direct:shipment` with an `aggregate` correlating on 
`${variable.orderId}` and a fixed
    `completionSize: 2`; only the two-line order completes.
 3. Replace the fixed size by `completionSizeExpression` with 
`${header.CamelSplitSize}`.
 4. Add `marshal` with `json` and log the shipment.
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/route/aggregator/aggregator.camel.yaml
 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/route/aggregator/aggregator.camel.yaml
index 5148ba54b6b8..9d07624b2941 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/route/aggregator/aggregator.camel.yaml
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/route/aggregator/aggregator.camel.yaml
@@ -13,7 +13,7 @@
         - unmarshal:
             json:
               library: Jackson
-        - setHeader:
+        - setVariable:
             name: orderId
             expression:
               simple:
@@ -24,7 +24,7 @@
                 expression: "${body[lines]}"
             steps:
               - log:
-                  message: "Picked ${body[qty]} x ${body[sku]} for 
${header.orderId}"
+                  message: "Picked ${body[qty]} x ${body[sku]} for 
${variable.orderId}"
               - to:
                   uri: direct
                   parameters:
@@ -40,7 +40,7 @@
             aggregationStrategy: 
"#class:org.apache.camel.processor.aggregate.GroupedBodyAggregationStrategy"
             correlationExpression:
               simple:
-                expression: "${header.orderId}"
+                expression: "${variable.orderId}"
             completionSizeExpression:
               simple:
                 expression: "${header.CamelSplitSize}"
@@ -49,4 +49,4 @@
                   json:
                     library: Jackson
               - log:
-                  message: "Shipment for ${header.orderId} complete: ${body}"
+                  message: "Shipment for ${variable.orderId} complete: ${body}"
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/route/enrich-and-dedupe/README.md
 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/route/enrich-and-dedupe/README.md
index 541594325463..b684f52b1463 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/route/enrich-and-dedupe/README.md
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/route/enrich-and-dedupe/README.md
@@ -37,8 +37,8 @@ The copies of the accepted orders land in `audit/`. Stop the 
example with `ctrl`
 - `idempotentConsumer` computes the order id with Simple and checks it against 
the repository. With
   `skipDuplicate: false` a duplicate is not dropped but marked with the 
exchange property `CamelDuplicateMessage`,
   so the `choice` can log it.
-- `pollEnrich` reads the customer's file. The file name is computed into a 
header first: the file consumer that
-  `pollEnrich` uses evaluates `fileName` with the headers of the message, not 
its body. `variableReceive: customer`
+- `pollEnrich` reads the customer's file. The file name is computed into a 
variable first: the file consumer that
+  `pollEnrich` uses evaluates `fileName` with the variables and headers of the 
message, not its body. `variableReceive: customer`
   keeps the customer in a variable, so the order stays the body, and 
`unmarshal` with `variableSend` and
   `variableReceive` parses the variable in place.
 - `wireTap` sends a copy of the order to the `audit` route and goes on at 
once: the audit never holds the order up.
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/route/enrich-and-dedupe/enrich-and-dedupe.camel.yaml
 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/route/enrich-and-dedupe/enrich-and-dedupe.camel.yaml
index f81fb64b3309..b5c058c68aa8 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/route/enrich-and-dedupe/enrich-and-dedupe.camel.yaml
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/route/enrich-and-dedupe/enrich-and-dedupe.camel.yaml
@@ -38,10 +38,10 @@
                     steps:
                       - log:
                           message: "Order ${body[orderId]} accepted"
-                      # the file name goes in a header: the file consumer of 
pollEnrich evaluates fileName with
-                      # the headers of the message, not its body; the customer 
goes to a variable, so the order
-                      # stays the body
-                      - setHeader:
+                      # the file name goes in a variable: the file consumer of 
pollEnrich evaluates fileName with
+                      # the variables and headers of the message, not its 
body; the customer goes to a variable,
+                      # so the order stays the body
+                      - setVariable:
                           name: customerFile
                           expression:
                             simple:
@@ -49,7 +49,7 @@
                       - pollEnrich:
                           expression:
                             simple:
-                              expression: 
"file:customers?fileName=${header.customerFile}&noop=true&idempotent=false"
+                              expression: 
"file:customers?fileName=${variable.customerFile}&noop=true&idempotent=false"
                           timeout: 2000
                           variableReceive: customer
                       - unmarshal:
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/route/order-lines/README.md
 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/route/order-lines/README.md
index 2659d8d2ebd3..17b346fad6d5 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/route/order-lines/README.md
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/route/order-lines/README.md
@@ -1,7 +1,7 @@
 # Order lines
 
 An order is one message with several lines; the warehouse picks one line at a 
time. The splitter turns the order
-into one message per line, and the order id travels along in a header.
+into one message per line, and the order id travels along in a variable.
 
 ## What you will see
 
@@ -32,8 +32,9 @@ can be repeated.
 
 - The order is parsed with `unmarshal` and `json`, so `${body[lines]}` is a 
list and `${body[lines].size()}` its
   length.
-- `setHeader` keeps the order id before the split: headers are copied to every 
split message, so each pick line
-  knows its order.
+- `setVariable` keeps the order id before the split: every split message gets 
a copy of the variables, so each pick
+  line knows its order. A variable, not a header: a header is sent on with the 
message to the next endpoint, and
+  the order id is only for the route itself.
 - `split` with `${body[lines]}` runs its steps once per line with that line as 
the body; `CamelSplitIndex` and
   `CamelSplitSize` are available inside if a count is needed.
 - After the split the route continues with the original order, which logs the 
confirmation.
@@ -42,7 +43,7 @@ can be repeated.
 
 1. A `file` route on `orders` that unmarshals each order and logs the number 
of lines.
 2. Add `split` over `${body[lines]}` and log `${body[sku]}` inside it.
-3. Keep the order id in a header before the split and use it in the pick line.
+3. Keep the order id in a variable before the split and use it in the pick 
line.
 4. Log the confirmation after the split and notice the body is the whole order 
again.
 
 ## Try changing
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/route/order-lines/order-lines.camel.yaml
 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/route/order-lines/order-lines.camel.yaml
index 9f8c2ad5c3d5..be0d10d55135 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/route/order-lines/order-lines.camel.yaml
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/route/order-lines/order-lines.camel.yaml
@@ -1,5 +1,5 @@
 # An order is one message with several lines; the warehouse picks one line at 
a time. The splitter
-# turns the order into one message per line, and the split messages keep the 
order id in a header.
+# turns the order into one message per line, and the split messages keep the 
order id in a variable.
 - route:
     id: order-lines
     from:
@@ -12,19 +12,19 @@
         - unmarshal:
             json:
               library: Jackson
-        - setHeader:
+        - setVariable:
             name: orderId
             expression:
               simple:
                 expression: "${body[orderId]}"
         - log:
-            message: "Order ${header.orderId} with ${body[lines].size()} 
line(s)"
+            message: "Order ${variable.orderId} with ${body[lines].size()} 
line(s)"
         - split:
             expression:
               simple:
                 expression: "${body[lines]}"
             steps:
               - log:
-                  message: "  pick ${body[qty]} x ${body[sku]} for 
${header.orderId}"
+                  message: "  pick ${body[qty]} x ${body[sku]} for 
${variable.orderId}"
         - log:
-            message: "Order ${header.orderId}: all ${body[lines].size()} 
line(s) sent to picking"
+            message: "Order ${variable.orderId}: all ${body[lines].size()} 
line(s) sent to picking"
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/run/order-generator/README.md
 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/run/order-generator/README.md
index 18fc09f74ec8..203a087be9b1 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/run/order-generator/README.md
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/run/order-generator/README.md
@@ -27,7 +27,7 @@ Stop it with `ctrl` + `c`, or from another terminal with 
`camel stop order-gener
 ## How it works
 
 - `order-generator.camel.yaml` is the route: a `timer` fires every 
`order.period` milliseconds, a
-  `setHeader` asks the `orderNumber` bean for the next number with a method 
expression, a `setBody`
+  `setVariable` asks the `orderNumber` bean for the next number with a method 
expression, a `setBody`
   builds the order as JSON with the simple language, and a `log` prints it.
 - `OrderNumber.java` is a plain Java class next to the route. `beans.yaml` 
declares it as the bean
   `orderNumber` and sets its first number from a property.
@@ -39,9 +39,9 @@ Stop it with `ctrl` + `c`, or from another terminal with 
`camel stop order-gener
 Ask your assistant, or type it yourself, one step at a time, and run after 
each:
 
 1. A timer route that logs "New order" every five seconds.
-2. Set a header `orderId` to a constant `ORD-1001` and log "New order 
${header.orderId}".
+2. Set a variable `orderId` to a constant `ORD-1001` and log "New order 
${variable.orderId}".
 3. Add a Java class `OrderNumber` with a method `next()` that returns `ORD-` 
and a counter, declare it
-   in `beans.yaml`, and set the header from the bean's method instead of the 
constant.
+   in `beans.yaml`, and set the variable from the bean's method instead of the 
constant.
 4. Set the body to a JSON order with the order id, a random customer and one 
line, and log the body.
 5. Move the period and the first order number to `application.properties`.
 
@@ -49,7 +49,7 @@ Ask your assistant, or type it yourself, one step at a time, 
and run after each:
 
 - `order.period=1000` for an order every second.
 - Add a second line to the order, or pick the sku at random from two products.
-- Log only the order id and the number of lines: `${header.orderId} has 
${body.lines.size()} line(s)`
+- Log only the order id and the number of lines: `${variable.orderId} has 
${body.lines.size()} line(s)`
   needs the body as an object; the `json-transform` example on the next rung 
shows how.
 
 ## Integration testing
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/run/order-generator/order-generator.camel.yaml
 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/run/order-generator/order-generator.camel.yaml
index 514f42b966b8..3bcff450f775 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/run/order-generator/order-generator.camel.yaml
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/run/order-generator/order-generator.camel.yaml
@@ -8,7 +8,7 @@
         timerName: orders
         period: "{{order.period}}"
       steps:
-        - setHeader:
+        - setVariable:
             name: orderId
             expression:
               method:
@@ -18,7 +18,7 @@
             expression:
               simple:
                 expression: |-
-                  {"orderId": "${header.orderId}", "customer": 
"C-${random(100,999)}", "country": "DK",
+                  {"orderId": "${variable.orderId}", "customer": 
"C-${random(100,999)}", "country": "DK",
                    "lines": [{"sku": "CAMEL-TSHIRT", "qty": ${random(1,3)}, 
"price": 19.95}], "status": "paid"}
         - log:
-            message: "New order ${header.orderId}: ${body}"
+            message: "New order ${variable.orderId}: ${body}"
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/transform/csv-to-json/README.md
 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/transform/csv-to-json/README.md
index 8ed95b6f7301..05635c97f0ce 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/transform/csv-to-json/README.md
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/transform/csv-to-json/README.md
@@ -30,7 +30,7 @@ camel run *
 - `unmarshal` with the `csv` data format reads `inbox/invoices.csv`; 
`captureHeaderRecord` takes the first line
   as the field names and `useMaps` makes each following line a map.
 - `split` turns the list of maps into one message per invoice.
-- Inside the split, the invoice id is kept in a header, `marshal` with `json` 
writes the map as JSON, and the
+- Inside the split, the invoice id is kept in a variable, `marshal` with 
`json` writes the map as JSON, and the
   `file` producer names the output file after the invoice.
 - Values are strings, as in the CSV; the `data-mapping` example shows how to 
compute and type fields.
 
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/transform/csv-to-json/csv-to-json.camel.yaml
 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/transform/csv-to-json/csv-to-json.camel.yaml
index 4fdf03dba037..a020cd3f5f77 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/transform/csv-to-json/csv-to-json.camel.yaml
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/transform/csv-to-json/csv-to-json.camel.yaml
@@ -18,7 +18,7 @@
               simple:
                 expression: "${body}"
             steps:
-              - setHeader:
+              - setVariable:
                   name: invoiceId
                   expression:
                     simple:
@@ -27,9 +27,9 @@
                   json:
                     library: Jackson
               - log:
-                  message: "Invoice ${header.invoiceId}: ${body}"
+                  message: "Invoice ${variable.invoiceId}: ${body}"
               - to:
                   uri: file
                   parameters:
                     directoryName: outbox
-                    fileName: "${header.invoiceId}.json"
+                    fileName: "${variable.invoiceId}.json"
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/transform/json-transform/README.md
 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/transform/json-transform/README.md
index f7e3d2cc2546..1ad285f5e679 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/transform/json-transform/README.md
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/transform/json-transform/README.md
@@ -28,7 +28,8 @@ camel run *
 ## How it works
 
 - The order comes from `order.json`; `resource:file:` in a constant expression 
loads a file as the body.
-- `jsonpath` expressions pick the order id and the number of lines into 
headers.
+- `jsonpath` expressions pick the order id and the number of lines into 
variables, which stay with the route and are
+  not sent on with the message as headers would be.
 - `transform` with a `jq` expression builds a new document from the old one: 
`.orderId` becomes `order`, and
   `[.lines[] | {sku, qty}]` keeps two fields of every line.
 - The Camel CLI adds the jq and jsonpath languages on its own.
@@ -36,7 +37,7 @@ camel run *
 ## Build it step by step
 
 1. A one-shot timer route that sets the body from `order.json` and logs it.
-2. Read the order id into a header with `jsonpath: $.orderId` and log it.
+2. Read the order id into a variable with `jsonpath: $.orderId` and log it.
 3. Add the number of lines with `jsonpath: $.lines.length()`.
 4. Add a `transform` step with a jq expression that keeps only the order id, 
and log the result.
 5. Extend the jq expression with the country and the pick list of sku and qty 
per line.
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/transform/json-transform/json-transform.camel.yaml
 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/transform/json-transform/json-transform.camel.yaml
index 933bb41d7f35..e17ecdda0b5a 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/transform/json-transform/json-transform.camel.yaml
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/examples/transform/json-transform/json-transform.camel.yaml
@@ -12,18 +12,18 @@
             expression:
               constant:
                 expression: "resource:file:order.json"
-        - setHeader:
+        - setVariable:
             name: orderId
             expression:
               jsonpath:
                 expression: "$.orderId"
-        - setHeader:
+        - setVariable:
             name: itemCount
             expression:
               jsonpath:
                 expression: "$.lines.length()"
         - log:
-            message: "Order ${header.orderId} with ${header.itemCount} lines: 
${body}"
+            message: "Order ${variable.orderId} with ${variable.itemCount} 
lines: ${body}"
         - transform:
             expression:
               jq:

Reply via email to