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-jbang-examples.git
The following commit(s) were added to refs/heads/main by this push:
new d7463bf CAMEL-25517: http-client keeps the order id, sku and quantity
in variables (#104)
d7463bf is described below
commit d7463bf7dcc7bd0bc09a11d38fe0f8313bbb3725
Author: Claus Ibsen <[email protected]>
AuthorDate: Sat Oct 10 10:43:50 2026 +0200
CAMEL-25517: http-client keeps the order id, sku and quantity in variables
(#104)
Camel favours variables for the values a route keeps for itself: like
exchange properties they stay
in the route (headers would travel on the HTTP request), and the README and
the step-by-step prompt
now say variables too.
Claude-Session: https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
---
camel-jbang-example-catalog.json | 2 +-
connect/http-client/README.md | 10 +++++-----
connect/http-client/http-client.camel.yaml | 18 +++++++++---------
connect/http-client/metadata.json | 2 +-
4 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/camel-jbang-example-catalog.json b/camel-jbang-example-catalog.json
index 4c5c027..e6106cf 100644
--- a/camel-jbang-example-catalog.json
+++ b/camel-jbang-example-catalog.json
@@ -540,7 +540,7 @@
],
"eips": [
"split",
- "setProperty",
+ "setVariable",
"toD",
"choice",
"unmarshal",
diff --git a/connect/http-client/README.md b/connect/http-client/README.md
index f035653..63df4c8 100644
--- a/connect/http-client/README.md
+++ b/connect/http-client/README.md
@@ -32,12 +32,12 @@ repeated. The stock levels are in `stock.json`.
## How it works
- The client splits each order into lines, as `order-lines` does, and calls
`toD` with
- `http://localhost:8080/stock/${exchangeProperty.sku}`: `toD` because the URI
is built per message.
-- The SKU, the quantity and the order id are kept in exchange properties, not
headers: headers travel on the
+ `http://localhost:8080/stock/${variable.sku}`: `toD` because the URI is
built per message.
+- The SKU, the quantity and the order id are kept in variables, not headers:
headers travel on the
HTTP request, and a header named `sku` would collide with the `{sku}` path
parameter on the server side.
- Properties stay in the route.
+ Variables stay in the route.
- The body is set to null before the call: a GET has no body, and the order
line would otherwise be sent. The
- response replaces the body, which is why the line was saved in properties
first.
+ response replaces the body, which is why the line was saved in variables
first.
- `throwExceptionOnFailure=false` turns a 404 into a normal response with
`CamelHttpResponseCode` set, so the
`choice` can log it instead of the error handler.
@@ -45,7 +45,7 @@ repeated. The stock levels are in `stock.json`.
1. Start from `stock-api` and add a `file` route on `orders` that logs each
order.
2. Split the lines and call `http://localhost:8080/stock/CAMEL-MUG` with a
fixed SKU; log the response body.
-3. Build the URI from the line with `toD` and a property; notice the body is
gone after the call.
+3. Build the URI from the line with `toD` and a variable; notice the body is
gone after the call.
4. Add `throwExceptionOnFailure=false` and the `choice` on the response code
and the quantity.
## Try changing
diff --git a/connect/http-client/http-client.camel.yaml
b/connect/http-client/http-client.camel.yaml
index a73f67e..0b342e0 100644
--- a/connect/http-client/http-client.camel.yaml
+++ b/connect/http-client/http-client.camel.yaml
@@ -65,8 +65,8 @@
- unmarshal:
json:
library: Jackson
- # exchange properties stay in the route; headers would travel on the
HTTP request
- - setProperty:
+ # variables stay in the route; headers would travel on the HTTP request
+ - setVariable:
name: orderId
expression:
simple:
@@ -76,12 +76,12 @@
simple:
expression: "${body[lines]}"
steps:
- - setProperty:
+ - setVariable:
name: sku
expression:
simple:
expression: "${body[sku]}"
- - setProperty:
+ - setVariable:
name: needed
expression:
simple:
@@ -92,7 +92,7 @@
simple:
expression: "${null}"
- toD:
- uri:
"http://localhost:8080/stock/${exchangeProperty.sku}?throwExceptionOnFailure=false"
+ uri:
"http://localhost:8080/stock/${variable.sku}?throwExceptionOnFailure=false"
- unmarshal:
json:
library: Jackson
@@ -103,14 +103,14 @@
expression: "${header.CamelHttpResponseCode} != 200"
steps:
- log:
- message: "${exchangeProperty.orderId}:
${body[error]} (HTTP ${header.CamelHttpResponseCode})"
+ message: "${variable.orderId}: ${body[error]}
(HTTP ${header.CamelHttpResponseCode})"
- expression:
simple:
- expression: "${body[qty]} >=
${exchangeProperty.needed}"
+ expression: "${body[qty]} >= ${variable.needed}"
steps:
- log:
- message: "${exchangeProperty.orderId}:
${exchangeProperty.sku} x ${exchangeProperty.needed}, ${body[qty]} in stock, ok"
+ message: "${variable.orderId}: ${variable.sku} x
${variable.needed}, ${body[qty]} in stock, ok"
otherwise:
steps:
- log:
- message: "${exchangeProperty.orderId}:
${exchangeProperty.sku} x ${exchangeProperty.needed}, only ${body[qty]} in
stock, back-order"
+ message: "${variable.orderId}: ${variable.sku} x
${variable.needed}, only ${body[qty]} in stock, back-order"
diff --git a/connect/http-client/metadata.json
b/connect/http-client/metadata.json
index 2487795..1649f52 100644
--- a/connect/http-client/metadata.json
+++ b/connect/http-client/metadata.json
@@ -14,7 +14,7 @@
],
"eips": [
"split",
- "setProperty",
+ "setVariable",
"toD",
"choice",
"unmarshal",