gnodet-bot commented on code in PR #28635:
URL: https://github.com/apache/camel/pull/28635#discussion_r4406593549
##########
core/camel-core-engine/src/main/docs/modules/eips/pages/enrich-eip.adoc:
##########
@@ -51,6 +51,72 @@ Enrich EIP is the most common content enricher that uses a
`Producer` to obtain
The content enricher (`enrich`) retrieves additional data from a _resource
endpoint_
to enrich an incoming message (contained in the _original exchange_).
+=== Keeping the message: the reply in a variable
+
+By default, the reply of the resource endpoint becomes the message, as with
`to`: the reply body replaces the body.
+To keep the message as it is, set `variableReceive`: the reply body is stored
in that variable, and the message body
+and headers stay unchanged. This is the simplest way to enrich, with no
aggregation strategy to write.
+
+For example, the body is an order that is sent to the stock service with
request-reply, and the order stays the body,
+so it can be sent on after the stock service has answered:
+
+[tabs]
+====
+Java::
++
+[source,java]
+----
+from("jms:queue:orders")
+ .enrich().constant("jms:queue:stock").variableReceive("stock")
+ .log("Stock service answered for ${header.orderId}: ${variable.stock}")
+ .to("jms:queue:reserved");
+----
+
+XML::
++
+[source,xml]
+----
+<route>
+ <from uri="jms:queue:orders"/>
+ <enrich variableReceive="stock">
+ <constant>jms:queue:stock</constant>
+ </enrich>
+ <log message="Stock service answered for ${header.orderId}:
${variable.stock}"/>
+ <to uri="jms:queue:reserved"/>
+</route>
+----
+
+YAML::
++
+[source,yaml]
+----
+- route:
+ from:
+ uri: jms:queue:orders
+ steps:
+ - enrich:
+ expression:
+ constant:
+ expression: jms:queue:stock
Review Comment:
💡 **Nit (still open) — YAML expression syntax inconsistency:** Same as the
catalog copy — existing YAML examples use the shorthand form. Suggest:
```suggestion
constant: jms:queue:stock
```
##########
core/camel-core-engine/src/main/docs/modules/eips/pages/enrich-eip.adoc:
##########
@@ -51,6 +51,72 @@ Enrich EIP is the most common content enricher that uses a
`Producer` to obtain
The content enricher (`enrich`) retrieves additional data from a _resource
endpoint_
to enrich an incoming message (contained in the _original exchange_).
+=== Keeping the message: the reply in a variable
+
+By default, the reply of the resource endpoint becomes the message, as with
`to`: the reply body replaces the body.
+To keep the message as it is, set `variableReceive`: the reply body is stored
in that variable, and the message body
+and headers stay unchanged. This is the simplest way to enrich, with no
aggregation strategy to write.
+
+For example, the body is an order that is sent to the stock service with
request-reply, and the order stays the body,
+so it can be sent on after the stock service has answered:
+
+[tabs]
+====
+Java::
++
+[source,java]
+----
+from("jms:queue:orders")
+ .enrich().constant("jms:queue:stock").variableReceive("stock")
+ .log("Stock service answered for ${header.orderId}: ${variable.stock}")
+ .to("jms:queue:reserved");
+----
+
+XML::
++
+[source,xml]
+----
+<route>
+ <from uri="jms:queue:orders"/>
+ <enrich variableReceive="stock">
+ <constant>jms:queue:stock</constant>
+ </enrich>
+ <log message="Stock service answered for ${header.orderId}:
${variable.stock}"/>
+ <to uri="jms:queue:reserved"/>
+</route>
+----
+
+YAML::
++
+[source,yaml]
+----
+- route:
+ from:
+ uri: jms:queue:orders
+ steps:
+ - enrich:
+ expression:
+ constant:
+ expression: jms:queue:stock
+ variableReceive: stock
+ - log:
+ message: "Stock service answered for ${header.orderId}:
${variable.stock}"
+ - to:
+ uri: jms:queue:reserved
+----
+====
+
+The headers of the reply are stored as variables too, named `header:stock.`
and the name of the header, such as
+`header:stock.JMSCorrelationID`. To send something other than the message body
to the resource endpoint,
Review Comment:
💡 **Nit (still open) — confusing wording:** Same as the catalog copy.
```suggestion
The headers of the reply are stored as variables too, using the pattern
`header:<variable>.<headerName>`, for example
`header:stock.JMSCorrelationID`. To send something other than the message
body to the resource endpoint,
```
##########
catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/enrich-eip.adoc:
##########
@@ -51,6 +51,72 @@ Enrich EIP is the most common content enricher that uses a
`Producer` to obtain
The content enricher (`enrich`) retrieves additional data from a _resource
endpoint_
to enrich an incoming message (contained in the _original exchange_).
+=== Keeping the message: the reply in a variable
+
+By default, the reply of the resource endpoint becomes the message, as with
`to`: the reply body replaces the body.
+To keep the message as it is, set `variableReceive`: the reply body is stored
in that variable, and the message body
+and headers stay unchanged. This is the simplest way to enrich, with no
aggregation strategy to write.
+
+For example, the body is an order that is sent to the stock service with
request-reply, and the order stays the body,
+so it can be sent on after the stock service has answered:
+
+[tabs]
+====
+Java::
++
+[source,java]
+----
+from("jms:queue:orders")
+ .enrich().constant("jms:queue:stock").variableReceive("stock")
+ .log("Stock service answered for ${header.orderId}: ${variable.stock}")
+ .to("jms:queue:reserved");
+----
+
+XML::
++
+[source,xml]
+----
+<route>
+ <from uri="jms:queue:orders"/>
+ <enrich variableReceive="stock">
+ <constant>jms:queue:stock</constant>
+ </enrich>
+ <log message="Stock service answered for ${header.orderId}:
${variable.stock}"/>
+ <to uri="jms:queue:reserved"/>
+</route>
+----
+
+YAML::
++
+[source,yaml]
+----
+- route:
+ from:
+ uri: jms:queue:orders
+ steps:
+ - enrich:
+ expression:
+ constant:
+ expression: jms:queue:stock
Review Comment:
💡 **Nit (still open) — YAML expression syntax inconsistency:** The existing
YAML examples in this file use the shorthand form (`constant: http:...`), but
this new block still uses the explicit nested form. Suggest using the shorthand
for consistency:
```suggestion
constant: jms:queue:stock
```
##########
catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/enrich-eip.adoc:
##########
@@ -51,6 +51,72 @@ Enrich EIP is the most common content enricher that uses a
`Producer` to obtain
The content enricher (`enrich`) retrieves additional data from a _resource
endpoint_
to enrich an incoming message (contained in the _original exchange_).
+=== Keeping the message: the reply in a variable
+
+By default, the reply of the resource endpoint becomes the message, as with
`to`: the reply body replaces the body.
+To keep the message as it is, set `variableReceive`: the reply body is stored
in that variable, and the message body
+and headers stay unchanged. This is the simplest way to enrich, with no
aggregation strategy to write.
+
+For example, the body is an order that is sent to the stock service with
request-reply, and the order stays the body,
+so it can be sent on after the stock service has answered:
+
+[tabs]
+====
+Java::
++
+[source,java]
+----
+from("jms:queue:orders")
+ .enrich().constant("jms:queue:stock").variableReceive("stock")
+ .log("Stock service answered for ${header.orderId}: ${variable.stock}")
+ .to("jms:queue:reserved");
+----
+
+XML::
++
+[source,xml]
+----
+<route>
+ <from uri="jms:queue:orders"/>
+ <enrich variableReceive="stock">
+ <constant>jms:queue:stock</constant>
+ </enrich>
+ <log message="Stock service answered for ${header.orderId}:
${variable.stock}"/>
+ <to uri="jms:queue:reserved"/>
+</route>
+----
+
+YAML::
++
+[source,yaml]
+----
+- route:
+ from:
+ uri: jms:queue:orders
+ steps:
+ - enrich:
+ expression:
+ constant:
+ expression: jms:queue:stock
+ variableReceive: stock
+ - log:
+ message: "Stock service answered for ${header.orderId}:
${variable.stock}"
+ - to:
+ uri: jms:queue:reserved
+----
+====
+
+The headers of the reply are stored as variables too, named `header:stock.`
and the name of the header, such as
+`header:stock.JMSCorrelationID`. To send something other than the message body
to the resource endpoint,
Review Comment:
💡 **Nit (still open) — confusing wording:** The phrase `` `header:stock.` ``
with a trailing dot inside the backtick span looks like a malformed variable
name. Suggest describing the pattern explicitly:
```suggestion
The headers of the reply are stored as variables too, using the pattern
`header:<variable>.<headerName>`, for example
`header:stock.JMSCorrelationID`. To send something other than the message
body to the resource endpoint,
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]