This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch fix/CAMEL-24720-doc-endpoint-examples
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 07aaaedf8fab1b81efeae54bfad39963b6c1be60
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Sep 17 21:01:52 2026 +0200

    CAMEL-24720: camel-jcache - the documentation shows the producer operations 
and the consumer of cache events, not only the JCache policy
    
    The page documented the JCachePolicy only, so it had no example of a 
jcache: endpoint. A producer section
    lists the operations, says how the action, the key and the body go 
together, and shows a PUT with the
    action option and a GET with the action header; a consumer section shows 
the event headers and the
    filteredEvents option.
    
    Co-Authored-By: Claude Fable 5.1 <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../camel/catalog/docs/jcache-component.adoc       | 149 +++++++++++++++++++++
 .../src/main/docs/jcache-component.adoc            | 149 +++++++++++++++++++++
 2 files changed, 298 insertions(+)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/jcache-component.adoc
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/jcache-component.adoc
index a22fcfaed2e5..aba87a4c06b4 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/jcache-component.adoc
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/jcache-component.adoc
@@ -29,6 +29,155 @@ include::partial$component-endpoint-headers.adoc[]
 
 == Usage
 
+=== Producer operations
+
+The producer performs one cache operation per message: the `action` option 
sets the default, and the
+`CamelJCacheAction` header overrides it per message. The operations are `PUT`, 
`PUTALL`, `PUTIFABSENT`, `GET`,
+`GETALL`, `GETANDREMOVE`, `GETANDREPLACE`, `GETANDPUT`, `REPLACE`, `REMOVE`, 
`REMOVEALL`, `CLEAR` and `INVOKE`.
+The `CamelJCacheKey` header names the entry (`CamelJCacheKeys`, a set of keys, 
for the `ALL` operations), the
+message body is the value to store, and a `GET` puts the value found in the 
body.
+
+Storing a value under a key:
+
+[tabs]
+====
+Java::
++
+[source,java]
+----
+from("direct:put")
+    .setHeader(JCacheConstants.KEY, constant("123"))
+    .to("jcache:orders?action=PUT");
+----
+
+XML::
++
+[source,xml]
+----
+<route>
+    <from uri="direct:put"/>
+    <setHeader name="CamelJCacheKey">
+        <constant>123</constant>
+    </setHeader>
+    <to uri="jcache:orders?action=PUT"/>
+</route>
+----
+
+YAML::
++
+[source,yaml]
+----
+- route:
+    from:
+      uri: direct:put
+      steps:
+        - setHeader:
+            name: CamelJCacheKey
+            expression:
+              constant:
+                expression: "123"
+        - to:
+            uri: jcache:orders?action=PUT
+----
+====
+
+Reading a value back, the operation chosen by the header:
+
+[tabs]
+====
+Java::
++
+[source,java]
+----
+from("direct:get")
+    .setHeader(JCacheConstants.ACTION, constant("GET"))
+    .setHeader(JCacheConstants.KEY, constant("123"))
+    .to("jcache:orders")
+    .log("Order 123 is ${body}");
+----
+
+XML::
++
+[source,xml]
+----
+<route>
+    <from uri="direct:get"/>
+    <setHeader name="CamelJCacheAction">
+        <constant>GET</constant>
+    </setHeader>
+    <setHeader name="CamelJCacheKey">
+        <constant>123</constant>
+    </setHeader>
+    <to uri="jcache:orders"/>
+    <log message="Order 123 is ${body}"/>
+</route>
+----
+
+YAML::
++
+[source,yaml]
+----
+- route:
+    from:
+      uri: direct:get
+      steps:
+        - setHeader:
+            name: CamelJCacheAction
+            expression:
+              constant:
+                expression: GET
+        - setHeader:
+            name: CamelJCacheKey
+            expression:
+              constant:
+                expression: "123"
+        - to:
+            uri: jcache:orders
+        - log:
+            message: "Order 123 is ${body}"
+----
+====
+
+=== Consuming cache events
+
+The consumer receives the events of the cache: the `CamelJCacheEventType` 
header is `CREATED`, `UPDATED`,
+`REMOVED` or `EXPIRED`, `CamelJCacheKey` is the key, the body is the value, 
and with `oldValueRequired=true`
+the `CamelJCacheOldValue` header is the previous value. The `filteredEvents` 
option names the events to leave
+out:
+
+[tabs]
+====
+Java::
++
+[source,java]
+----
+from("jcache:orders?filteredEvents=EXPIRED")
+    .log("Order ${header.CamelJCacheKey} was ${header.CamelJCacheEventType}: 
${body}");
+----
+
+XML::
++
+[source,xml]
+----
+<route>
+    <from uri="jcache:orders?filteredEvents=EXPIRED"/>
+    <log message="Order ${header.CamelJCacheKey} was 
${header.CamelJCacheEventType}: ${body}"/>
+</route>
+----
+
+YAML::
++
+[source,yaml]
+----
+- route:
+    from:
+      uri: jcache:orders?filteredEvents=EXPIRED
+      steps:
+        - log:
+            message: "Order ${header.CamelJCacheKey} was 
${header.CamelJCacheEventType}: ${body}"
+----
+====
+
 === JCache Policy
 
 The JCachePolicy is an interceptor around a route that caches the "result of 
the route" (the message body) after the route is completed.
diff --git a/components/camel-jcache/src/main/docs/jcache-component.adoc 
b/components/camel-jcache/src/main/docs/jcache-component.adoc
index a22fcfaed2e5..aba87a4c06b4 100644
--- a/components/camel-jcache/src/main/docs/jcache-component.adoc
+++ b/components/camel-jcache/src/main/docs/jcache-component.adoc
@@ -29,6 +29,155 @@ include::partial$component-endpoint-headers.adoc[]
 
 == Usage
 
+=== Producer operations
+
+The producer performs one cache operation per message: the `action` option 
sets the default, and the
+`CamelJCacheAction` header overrides it per message. The operations are `PUT`, 
`PUTALL`, `PUTIFABSENT`, `GET`,
+`GETALL`, `GETANDREMOVE`, `GETANDREPLACE`, `GETANDPUT`, `REPLACE`, `REMOVE`, 
`REMOVEALL`, `CLEAR` and `INVOKE`.
+The `CamelJCacheKey` header names the entry (`CamelJCacheKeys`, a set of keys, 
for the `ALL` operations), the
+message body is the value to store, and a `GET` puts the value found in the 
body.
+
+Storing a value under a key:
+
+[tabs]
+====
+Java::
++
+[source,java]
+----
+from("direct:put")
+    .setHeader(JCacheConstants.KEY, constant("123"))
+    .to("jcache:orders?action=PUT");
+----
+
+XML::
++
+[source,xml]
+----
+<route>
+    <from uri="direct:put"/>
+    <setHeader name="CamelJCacheKey">
+        <constant>123</constant>
+    </setHeader>
+    <to uri="jcache:orders?action=PUT"/>
+</route>
+----
+
+YAML::
++
+[source,yaml]
+----
+- route:
+    from:
+      uri: direct:put
+      steps:
+        - setHeader:
+            name: CamelJCacheKey
+            expression:
+              constant:
+                expression: "123"
+        - to:
+            uri: jcache:orders?action=PUT
+----
+====
+
+Reading a value back, the operation chosen by the header:
+
+[tabs]
+====
+Java::
++
+[source,java]
+----
+from("direct:get")
+    .setHeader(JCacheConstants.ACTION, constant("GET"))
+    .setHeader(JCacheConstants.KEY, constant("123"))
+    .to("jcache:orders")
+    .log("Order 123 is ${body}");
+----
+
+XML::
++
+[source,xml]
+----
+<route>
+    <from uri="direct:get"/>
+    <setHeader name="CamelJCacheAction">
+        <constant>GET</constant>
+    </setHeader>
+    <setHeader name="CamelJCacheKey">
+        <constant>123</constant>
+    </setHeader>
+    <to uri="jcache:orders"/>
+    <log message="Order 123 is ${body}"/>
+</route>
+----
+
+YAML::
++
+[source,yaml]
+----
+- route:
+    from:
+      uri: direct:get
+      steps:
+        - setHeader:
+            name: CamelJCacheAction
+            expression:
+              constant:
+                expression: GET
+        - setHeader:
+            name: CamelJCacheKey
+            expression:
+              constant:
+                expression: "123"
+        - to:
+            uri: jcache:orders
+        - log:
+            message: "Order 123 is ${body}"
+----
+====
+
+=== Consuming cache events
+
+The consumer receives the events of the cache: the `CamelJCacheEventType` 
header is `CREATED`, `UPDATED`,
+`REMOVED` or `EXPIRED`, `CamelJCacheKey` is the key, the body is the value, 
and with `oldValueRequired=true`
+the `CamelJCacheOldValue` header is the previous value. The `filteredEvents` 
option names the events to leave
+out:
+
+[tabs]
+====
+Java::
++
+[source,java]
+----
+from("jcache:orders?filteredEvents=EXPIRED")
+    .log("Order ${header.CamelJCacheKey} was ${header.CamelJCacheEventType}: 
${body}");
+----
+
+XML::
++
+[source,xml]
+----
+<route>
+    <from uri="jcache:orders?filteredEvents=EXPIRED"/>
+    <log message="Order ${header.CamelJCacheKey} was 
${header.CamelJCacheEventType}: ${body}"/>
+</route>
+----
+
+YAML::
++
+[source,yaml]
+----
+- route:
+    from:
+      uri: jcache:orders?filteredEvents=EXPIRED
+      steps:
+        - log:
+            message: "Order ${header.CamelJCacheKey} was 
${header.CamelJCacheEventType}: ${body}"
+----
+====
+
 === JCache Policy
 
 The JCachePolicy is an interceptor around a route that caches the "result of 
the route" (the message body) after the route is completed.

Reply via email to