You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gn...@apache.org on 2026/08/25 14:56:36 UTC
(camel) branch main updated: CAMEL-23239: Add camel-state-store component with pluggable key-value store
This is an automated email from the ASF dual-hosted git repository.
gnodet 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 677019d20802 CAMEL-23239: Add camel-state-store component with pluggable key-value store
677019d20802 is described below
commit 677019d208026271d8be4df8b8c8fb3a503f4307
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Tue Aug 25 16:56:30 2026 +0200
CAMEL-23239: Add camel-state-store component with pluggable key-value store
Adds a new camel-state-store component that provides a unified key-value store API
with pluggable backends (in-memory, Caffeine, Redis, Infinispan). Supports put, get,
delete, contains, keys, size, clear, putIfAbsent operations with optional per-entry TTL.
Co-authored-by: Claude Opus 4.6 <no...@anthropic.com>
---
bom/camel-bom/pom.xml | 20 +
catalog/camel-allcomponents/pom.xml | 20 +
.../org/apache/camel/catalog/components.properties | 1 +
.../camel/catalog/components/state-store.json | 42 ++
.../org/apache/camel/catalog/docs.properties | 1 +
.../camel/catalog/docs/state-store-component.adoc | 431 +++++++++++++++++++++
.../org/apache/camel/catalog/others.properties | 3 +
.../camel/catalog/others/state-store-caffeine.json | 14 +
.../catalog/others/state-store-infinispan.json | 14 +
.../camel/catalog/others/state-store-redis.json | 14 +
.../camel-state-store-caffeine/pom.xml | 64 +++
.../services/org/apache/camel/other.properties | 7 +
.../generated/resources/state-store-caffeine.json | 14 +
.../caffeine/CaffeineStateStoreBackend.java | 133 +++++++
.../caffeine/CaffeineStateStoreBackendTest.java | 198 ++++++++++
.../caffeine/CaffeineStateStorePropertiesTest.java | 95 +++++
.../camel-state-store-infinispan/pom.xml | 71 ++++
.../services/org/apache/camel/other.properties | 7 +
.../resources/state-store-infinispan.json | 14 +
.../infinispan/InfinispanStateStoreBackend.java | 135 +++++++
.../infinispan/InfinispanStateStoreBackendIT.java | 240 ++++++++++++
.../InfinispanStateStorePropertiesIT.java | 133 +++++++
.../camel-state-store-redis/pom.xml | 71 ++++
.../services/org/apache/camel/other.properties | 7 +
.../src/generated/resources/state-store-redis.json | 14 +
.../statestore/redis/RedisStateStoreBackend.java | 132 +++++++
.../statestore/redis/RedisStateStoreBackendIT.java | 204 ++++++++++
.../redis/RedisStateStorePropertiesIT.java | 83 ++++
.../camel-state-store/camel-state-store/pom.xml | 64 +++
.../statestore/StateStoreComponentConfigurer.java | 57 +++
.../statestore/StateStoreEndpointConfigurer.java | 60 +++
.../statestore/StateStoreEndpointUriFactory.java | 81 ++++
.../camel/component/statestore/state-store.json | 42 ++
.../services/org/apache/camel/component.properties | 7 +
.../org/apache/camel/component/state-store | 2 +
.../apache/camel/configurer/state-store-component | 2 +
.../apache/camel/configurer/state-store-endpoint | 2 +
.../apache/camel/urifactory/state-store-endpoint | 2 +
.../src/main/docs/state-store-component.adoc | 431 +++++++++++++++++++++
.../statestore/InMemoryStateStoreBackend.java | 128 ++++++
.../component/statestore/StateStoreBackend.java | 103 +++++
.../component/statestore/StateStoreComponent.java | 112 ++++++
.../component/statestore/StateStoreConstants.java | 41 ++
.../component/statestore/StateStoreEndpoint.java | 106 +++++
.../component/statestore/StateStoreOperations.java | 35 ++
.../component/statestore/StateStoreProducer.java | 132 +++++++
.../statestore/StateStoreAutoDiscoveryTest.java | 75 ++++
.../StateStoreMultiBackendFallbackTest.java | 69 ++++
.../camel/component/statestore/StateStoreTest.java | 269 +++++++++++++
.../component/statestore/StateStoreTtlTest.java | 78 ++++
components/camel-state-store/pom.xml | 42 ++
components/pom.xml | 1 +
.../org/apache/camel/main/components.properties | 1 +
.../modules/ROOT/examples/json/state-store.json | 1 +
docs/components/modules/ROOT/nav.adoc | 1 +
.../modules/ROOT/pages/state-store-component.adoc | 1 +
.../others/examples/json/state-store-caffeine.json | 1 +
.../examples/json/state-store-infinispan.json | 1 +
.../others/examples/json/state-store-redis.json | 1 +
.../component/ComponentsBuilderFactory.java | 13 +
.../dsl/StateStoreComponentBuilderFactory.java | 120 ++++++
.../builder/endpoint/EndpointBuilderFactory.java | 1 +
.../camel/builder/endpoint/EndpointBuilders.java | 1 +
.../builder/endpoint/EndpointHeaderBuilders.java | 13 +
.../builder/endpoint/StaticEndpointBuilders.java | 40 ++
.../dsl/StateStoreEndpointBuilderFactory.java | 316 +++++++++++++++
.../camel-component-known-dependencies.properties | 1 +
parent/pom.xml | 20 +
.../apache/camel/maven/packaging/MojoHelper.java | 3 +
69 files changed, 4658 insertions(+)
diff --git a/bom/camel-bom/pom.xml b/bom/camel-bom/pom.xml
index 8fc166a612b8..0be4749339df 100644
--- a/bom/camel-bom/pom.xml
+++ b/bom/camel-bom/pom.xml
@@ -2362,6 +2362,26 @@
<artifactId>camel-ssh</artifactId>
<version>4.23.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-state-store</artifactId>
+ <version>4.23.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-state-store-caffeine</artifactId>
+ <version>4.23.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-state-store-infinispan</artifactId>
+ <version>4.23.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-state-store-redis</artifactId>
+ <version>4.23.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-stax</artifactId>
diff --git a/catalog/camel-allcomponents/pom.xml b/catalog/camel-allcomponents/pom.xml
index e68db742e5d1..f042561cdc90 100644
--- a/catalog/camel-allcomponents/pom.xml
+++ b/catalog/camel-allcomponents/pom.xml
@@ -2137,6 +2137,26 @@
<artifactId>camel-ssh</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-state-store</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-state-store-caffeine</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-state-store-infinispan</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-state-store-redis</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-stax</artifactId>
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components.properties b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components.properties
index 7daa5f5e70f6..6dc929e6fe02 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components.properties
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components.properties
@@ -362,6 +362,7 @@ spring-ws
sql
sql-stored
ssh
+state-store
stax
stitch
stream
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/state-store.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/state-store.json
new file mode 100644
index 000000000000..d90c315d879c
--- /dev/null
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/state-store.json
@@ -0,0 +1,42 @@
+{
+ "component": {
+ "kind": "component",
+ "name": "state-store",
+ "title": "State Store",
+ "description": "Perform key-value operations against a pluggable state store backend.",
+ "deprecated": false,
+ "firstVersion": "4.23.0",
+ "label": "cache",
+ "javaType": "org.apache.camel.component.statestore.StateStoreComponent",
+ "supportLevel": "Preview",
+ "groupId": "org.apache.camel",
+ "artifactId": "camel-state-store",
+ "version": "4.23.0-SNAPSHOT",
+ "scheme": "state-store",
+ "extendsScheme": "",
+ "syntax": "state-store:storeName",
+ "async": false,
+ "api": false,
+ "consumerOnly": false,
+ "producerOnly": true,
+ "lenientProperties": false,
+ "browsable": false,
+ "remote": true
+ },
+ "componentProperties": {
+ "lazyStartProducer": { "index": 0, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail [...]
+ "autowiredEnabled": { "index": 1, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...]
+ },
+ "headers": {
+ "CamelStateStoreOperation": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "org.apache.camel.component.statestore.StateStoreOperations", "enum": [ "put", "putIfAbsent", "get", "delete", "contains", "keys", "size", "clear" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation to perform", "constantName": "org.apache.camel.component.statestore.StateSt [...]
+ "CamelStateStoreKey": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The key to use for the operation", "constantName": "org.apache.camel.component.statestore.StateStoreConstants#KEY" },
+ "CamelStateStoreTtl": { "index": 2, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Per-message TTL override in milliseconds. Takes precedence over the endpoint ttl option.", "constantName": "org.apache.camel.component.statestore.StateStoreConstants#TTL" }
+ },
+ "properties": {
+ "storeName": { "index": 0, "kind": "path", "displayName": "Store Name", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the state store" },
+ "operation": { "index": 1, "kind": "parameter", "displayName": "Operation", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "org.apache.camel.component.statestore.StateStoreOperations", "enum": [ "put", "putIfAbsent", "get", "delete", "contains", "keys", "size", "clear" ], "deprecated": false, "autowired": false, "secret": false, "description": "The default operation to perform" },
+ "ttl": { "index": 2, "kind": "parameter", "displayName": "Ttl", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 0, "description": "Time-to-live in milliseconds for entries. 0 means no expiry." },
+ "lazyStartProducer": { "index": 3, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a produc [...]
+ "backend": { "index": 4, "kind": "parameter", "displayName": "Backend", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.statestore.StateStoreBackend", "deprecated": false, "autowired": false, "secret": false, "description": "The backend to use. If not set, auto-discovers a single StateStoreBackend from the registry, or falls back to an in-memory store." }
+ }
+}
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs.properties b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs.properties
index 2a66894d5d96..16bf340220ee 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs.properties
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs.properties
@@ -616,6 +616,7 @@ springdoc
sql-component
sql-stored-component
ssh-component
+state-store-component
stax-component
step-eip
stickyLoadBalancer-eip
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/state-store-component.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/state-store-component.adoc
new file mode 100644
index 000000000000..8d2537e9df3d
--- /dev/null
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/state-store-component.adoc
@@ -0,0 +1,431 @@
+= State Store Component
+:doctitle: State Store
+:shortname: state-store
+:artifactid: camel-state-store
+:description: Perform key-value operations against a pluggable state store backend.
+:since: 4.23
+:supportlevel: Preview
+:tabs-sync-option:
+:component-header: Only producer is supported
+
+*Since Camel {since}*
+
+*{component-header}*
+
+The State Store component provides a simple, unified key-value store API with pluggable backends.
+It is useful for caching, session state, and scenarios where you need a simple object store
+(similar to MuleSoft's Object Store).
+
+By default, an in-memory backend is used (based on `ConcurrentHashMap`), but you can plug in
+any custom backend by implementing the `StateStoreBackend` interface or using one of the
+provided backend modules:
+
+== When to use State Store vs individual components
+
+Camel also provides dedicated components for xref:infinispan-component.adoc[Infinispan],
+xref:spring-redis-component.adoc[Redis], and xref:caffeine-cache-component.adoc[Caffeine].
+Use the dedicated component when you need the full feature set of a specific technology
+(e.g., Infinispan queries, Redis pub/sub, Caffeine statistics).
+
+Use State Store when:
+
+* You need a *simple key-value API* and want to switch backends without changing route logic.
+* You are *migrating from MuleSoft* and want an Object Store equivalent.
+* You want *backend portability* — develop with in-memory, deploy with Redis or Infinispan.
+* Your use case is limited to *put, get, delete, contains, keys* operations.
+
+[width="100%",cols="1,2,1",options="header"]
+|===
+| Backend | Module | Description
+| In-Memory | `camel-state-store` | Default. Uses `ConcurrentHashMap` with lazy TTL expiry. No external dependencies.
+| Caffeine | `camel-state-store-caffeine` | High-performance local cache with proper eviction and per-entry TTL.
+| Redis | `camel-state-store-redis` | Distributed store via Redisson. Supports per-entry TTL natively.
+| Infinispan | `camel-state-store-infinispan` | Distributed cache via Hot Rod client. Supports per-entry TTL via lifespan.
+|===
+
+== URI Format
+
+----
+state-store:storeName[?options]
+----
+
+Where `storeName` is a logical name for the store. Endpoints with the same `storeName`
+share the same backend instance within the same `CamelContext`.
+
+// component-configure options: START
+include::partial$component-configure-options.adoc[]
+// component-configure options: END
+
+// component options: START
+include::partial$component-configure-options.adoc[]
+include::partial$component-endpoint-options.adoc[]
+include::partial$component-endpoint-headers.adoc[]
+// component options: END
+
+// endpoint options: START
+// endpoint options: END
+
+== Operations
+
+The operation to perform is set via the URI option `operation` or the header `CamelStateStoreOperation`.
+
+[width="100%",cols="1,2,2,2",options="header"]
+|===
+| Operation | Description | Body (input) | Result (body output)
+| `put` | Store a value | The value to store | The previous value (or null)
+| `putIfAbsent` | Store only if key absent | The value to store | The existing value (or null if stored)
+| `get` | Retrieve a value | ignored | The stored value (or null)
+| `delete` | Remove a value | ignored | The removed value (or null)
+| `contains` | Check if key exists | ignored | Boolean
+| `keys` | List all keys | ignored | Set<String>
+| `size` | Count entries | ignored | Integer
+| `clear` | Remove all entries | ignored | null
+|===
+
+The key is specified via the header `CamelStateStoreKey` (required for `put`, `putIfAbsent`, `get`, `delete`, `contains`).
+
+== TTL (Time-to-Live)
+
+You can set a TTL (in milliseconds) for entries in two ways:
+
+* *Endpoint option*: applies to all `put`/`putIfAbsent` operations on that endpoint.
++
+----
+state-store:myStore?operation=put&ttl=60000
+----
+
+* *Per-message header*: the header `CamelStateStoreTtl` (Long) overrides the endpoint TTL for that message.
++
+[source,java]
+----
+from("direct:store")
+ .setHeader("CamelStateStoreKey", constant("myKey"))
+ .setHeader("CamelStateStoreTtl", constant(30000L))
+ .to("state-store:myStore?operation=put");
+----
+
+A TTL of `0` (default) means no expiry.
+
+== Examples
+
+=== Java DSL
+
+[tabs]
+====
+Put and Get::
++
+[source,java]
+----
+from("direct:store")
+ .setHeader("CamelStateStoreKey", constant("myKey"))
+ .to("state-store:myStore?operation=put");
+
+from("direct:retrieve")
+ .setHeader("CamelStateStoreKey", constant("myKey"))
+ .to("state-store:myStore?operation=get");
+----
+
+Dynamic operation via header::
++
+[source,java]
+----
+from("direct:dynamic")
+ .setHeader("CamelStateStoreOperation", constant("put"))
+ .setHeader("CamelStateStoreKey", constant("myKey"))
+ .to("state-store:myStore");
+----
+
+Put if absent::
++
+[source,java]
+----
+from("direct:init")
+ .setHeader("CamelStateStoreKey", constant("counter"))
+ .to("state-store:myStore?operation=putIfAbsent");
+----
+====
+
+=== YAML DSL
+
+[source,yaml]
+----
+- route:
+ from:
+ uri: direct:store
+ steps:
+ - setHeader:
+ name: CamelStateStoreKey
+ constant: myKey
+ - to:
+ uri: state-store:myStore?operation=put
+----
+
+== Backends
+
+=== Backend auto-discovery
+
+If no `backend` option is specified on the endpoint, the component automatically looks up a
+`StateStoreBackend` bean from the Camel registry. If exactly one is found, it is used for all
+endpoints. If none is found, the default in-memory backend is used.
+
+This means you can configure a backend once (via Java or properties) and all `state-store`
+endpoints will use it without needing `backend=#beanName` on each endpoint URI.
+
+=== Configuring backends via properties
+
+Backends can be configured entirely via `application.properties` using Camel's `camel.beans.*`
+syntax, without writing any Java code. This is especially useful for YAML DSL or Camel JBang users.
+
+[tabs]
+====
+Caffeine::
++
+[source,properties]
+----
+# application.properties
+camel.beans.caffeineBackend = #class:org.apache.camel.component.statestore.caffeine.CaffeineStateStoreBackend
+camel.beans.caffeineBackend.maximumSize = 50000
+----
+
+Redis::
++
+[source,properties]
+----
+# application.properties
+camel.beans.redisBackend = #class:org.apache.camel.component.statestore.redis.RedisStateStoreBackend
+camel.beans.redisBackend.redisUrl = redis://myhost:6379
+camel.beans.redisBackend.mapName = my-app-state
+----
+
+Infinispan::
++
+[source,properties]
+----
+# application.properties
+camel.beans.infinispanBackend = #class:org.apache.camel.component.statestore.infinispan.InfinispanStateStoreBackend
+camel.beans.infinispanBackend.hosts = myhost:11222
+camel.beans.infinispanBackend.cacheName = my-cache
+----
+====
+
+With the backend configured via properties and auto-discovery, no `backend=#...` reference
+is needed in the route:
+
+[source,yaml]
+----
+- route:
+ from:
+ uri: direct:store
+ steps:
+ - setHeader:
+ name: CamelStateStoreKey
+ constant: myKey
+ - to:
+ uri: state-store:myStore?operation=put
+----
+
+=== In-Memory (default)
+
+The default backend stores entries in a `ConcurrentHashMap`. TTL expiry is lazy -- entries are
+checked and removed on access rather than by a background thread.
+
+No additional dependency is needed beyond `camel-state-store`.
+
+=== Caffeine
+
+Add the dependency:
+
+[source,xml]
+----
+<dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-state-store-caffeine</artifactId>
+</dependency>
+----
+
+[tabs]
+====
+Java::
++
+[source,java]
+----
+@BindToRegistry("caffeineBackend")
+public CaffeineStateStoreBackend caffeine() {
+ CaffeineStateStoreBackend backend = new CaffeineStateStoreBackend();
+ backend.setMaximumSize(50_000); // default is 10,000
+ return backend;
+}
+----
+
+Properties::
++
+[source,properties]
+----
+camel.beans.caffeineBackend = #class:org.apache.camel.component.statestore.caffeine.CaffeineStateStoreBackend
+camel.beans.caffeineBackend.maximumSize = 50000
+----
+====
+
+With auto-discovery, the backend is picked up automatically. You can also reference it explicitly:
+
+[source,java]
+----
+from("direct:store")
+ .to("state-store:myStore?operation=put&backend=#caffeineBackend");
+----
+
+Caffeine provides proper eviction policies and active TTL expiration using variable expiry.
+
+=== Redis
+
+Add the dependency:
+
+[source,xml]
+----
+<dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-state-store-redis</artifactId>
+</dependency>
+----
+
+[tabs]
+====
+Java::
++
+[source,java]
+----
+@BindToRegistry("redisBackend")
+public RedisStateStoreBackend redis() {
+ RedisStateStoreBackend backend = new RedisStateStoreBackend();
+ backend.setRedisUrl("redis://myhost:6379");
+ backend.setMapName("my-app-state"); // Redis map name
+ return backend;
+}
+----
+
+Properties::
++
+[source,properties]
+----
+camel.beans.redisBackend = #class:org.apache.camel.component.statestore.redis.RedisStateStoreBackend
+camel.beans.redisBackend.redisUrl = redis://myhost:6379
+camel.beans.redisBackend.mapName = my-app-state
+----
+====
+
+You can also inject a pre-configured `RedissonClient`:
+
+[source,java]
+----
+backend.setRedisson(existingRedissonClient);
+----
+
+Redis provides native per-entry TTL via `RMapCache`. Data is distributed and persisted according
+to your Redis configuration.
+
+=== Infinispan
+
+Add the dependency:
+
+[source,xml]
+----
+<dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-state-store-infinispan</artifactId>
+</dependency>
+----
+
+[tabs]
+====
+Java::
++
+[source,java]
+----
+@BindToRegistry("infinispanBackend")
+public InfinispanStateStoreBackend infinispan() {
+ InfinispanStateStoreBackend backend = new InfinispanStateStoreBackend();
+ backend.setHosts("myhost:11222");
+ backend.setCacheName("my-cache");
+ return backend;
+}
+----
+
+Properties::
++
+[source,properties]
+----
+camel.beans.infinispanBackend = #class:org.apache.camel.component.statestore.infinispan.InfinispanStateStoreBackend
+camel.beans.infinispanBackend.hosts = myhost:11222
+camel.beans.infinispanBackend.cacheName = my-cache
+----
+====
+
+You can also inject a pre-configured `RemoteCacheManager`:
+
+[source,java]
+----
+backend.setCacheManager(existingCacheManager);
+----
+
+Infinispan provides native per-entry TTL via the lifespan parameter and supports distributed caching.
+
+== Custom Backend
+
+Implement the `StateStoreBackend` interface to create your own backend:
+
+[source,java]
+----
+public class MyCustomBackend implements StateStoreBackend {
+
+ @Override
+ public Object put(String key, Object value, long ttlMillis) {
+ // store the value, return previous
+ }
+
+ @Override
+ public Object get(String key) {
+ // retrieve the value
+ }
+
+ @Override
+ public Object delete(String key) {
+ // remove and return the value
+ }
+
+ @Override
+ public boolean contains(String key) {
+ // check existence
+ }
+
+ @Override
+ public Set<String> keys() {
+ // return all keys
+ }
+
+ @Override
+ public void clear() {
+ // remove all entries
+ }
+
+ @Override
+ public void start() {
+ // initialize connections
+ }
+
+ @Override
+ public void stop() {
+ // clean up resources
+ }
+}
+----
+
+The `putIfAbsent` and `size` methods have default implementations but can be overridden
+for better performance with backends that support these operations natively.
+
+Then reference it via bean or let auto-discovery find it:
+
+[source,java]
+----
+from("direct:store")
+ .to("state-store:myStore?operation=put&backend=#myCustomBackend");
+----
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others.properties b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others.properties
index 7dd8b85a93c5..bc0d33bc7533 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others.properties
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others.properties
@@ -60,6 +60,9 @@ spring-cloud-config
spring-main
spring-security
spring-xml
+state-store-caffeine
+state-store-infinispan
+state-store-redis
telemetry
telemetry-dev
test-junit5
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/state-store-caffeine.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/state-store-caffeine.json
new file mode 100644
index 000000000000..fc311aa76cb2
--- /dev/null
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/state-store-caffeine.json
@@ -0,0 +1,14 @@
+{
+ "other": {
+ "kind": "other",
+ "name": "state-store-caffeine",
+ "title": "State Store Caffeine",
+ "description": "Camel State Store backend using Caffeine cache",
+ "deprecated": false,
+ "firstVersion": "4.23.0",
+ "supportLevel": "Preview",
+ "groupId": "org.apache.camel",
+ "artifactId": "camel-state-store-caffeine",
+ "version": "4.23.0-SNAPSHOT"
+ }
+}
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/state-store-infinispan.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/state-store-infinispan.json
new file mode 100644
index 000000000000..a047688f0bcf
--- /dev/null
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/state-store-infinispan.json
@@ -0,0 +1,14 @@
+{
+ "other": {
+ "kind": "other",
+ "name": "state-store-infinispan",
+ "title": "State Store Infinispan",
+ "description": "Camel State Store backend using Infinispan remote (Hot Rod)",
+ "deprecated": false,
+ "firstVersion": "4.23.0",
+ "supportLevel": "Preview",
+ "groupId": "org.apache.camel",
+ "artifactId": "camel-state-store-infinispan",
+ "version": "4.23.0-SNAPSHOT"
+ }
+}
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/state-store-redis.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/state-store-redis.json
new file mode 100644
index 000000000000..20889cda5326
--- /dev/null
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/others/state-store-redis.json
@@ -0,0 +1,14 @@
+{
+ "other": {
+ "kind": "other",
+ "name": "state-store-redis",
+ "title": "State Store Redis",
+ "description": "Camel State Store backend using Redisson (Redis)",
+ "deprecated": false,
+ "firstVersion": "4.23.0",
+ "supportLevel": "Preview",
+ "groupId": "org.apache.camel",
+ "artifactId": "camel-state-store-redis",
+ "version": "4.23.0-SNAPSHOT"
+ }
+}
diff --git a/components/camel-state-store/camel-state-store-caffeine/pom.xml b/components/camel-state-store/camel-state-store-caffeine/pom.xml
new file mode 100644
index 000000000000..bed04dfb1a55
--- /dev/null
+++ b/components/camel-state-store/camel-state-store-caffeine/pom.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-state-store-parent</artifactId>
+ <version>4.23.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-state-store-caffeine</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Camel :: State Store :: Caffeine</name>
+ <description>Camel State Store backend using Caffeine cache</description>
+
+ <properties>
+ <firstVersion>4.23.0</firstVersion>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-state-store</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.github.ben-manes.caffeine</groupId>
+ <artifactId>caffeine</artifactId>
+ </dependency>
+
+ <!-- testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-main-junit5</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/components/camel-state-store/camel-state-store-caffeine/src/generated/resources/META-INF/services/org/apache/camel/other.properties b/components/camel-state-store/camel-state-store-caffeine/src/generated/resources/META-INF/services/org/apache/camel/other.properties
new file mode 100644
index 000000000000..f873d149c96f
--- /dev/null
+++ b/components/camel-state-store/camel-state-store-caffeine/src/generated/resources/META-INF/services/org/apache/camel/other.properties
@@ -0,0 +1,7 @@
+# Generated by camel build tools - do NOT edit this file!
+name=state-store-caffeine
+groupId=org.apache.camel
+artifactId=camel-state-store-caffeine
+version=4.23.0-SNAPSHOT
+projectName=Camel :: State Store :: Caffeine
+projectDescription=Camel State Store backend using Caffeine cache
diff --git a/components/camel-state-store/camel-state-store-caffeine/src/generated/resources/state-store-caffeine.json b/components/camel-state-store/camel-state-store-caffeine/src/generated/resources/state-store-caffeine.json
new file mode 100644
index 000000000000..fc311aa76cb2
--- /dev/null
+++ b/components/camel-state-store/camel-state-store-caffeine/src/generated/resources/state-store-caffeine.json
@@ -0,0 +1,14 @@
+{
+ "other": {
+ "kind": "other",
+ "name": "state-store-caffeine",
+ "title": "State Store Caffeine",
+ "description": "Camel State Store backend using Caffeine cache",
+ "deprecated": false,
+ "firstVersion": "4.23.0",
+ "supportLevel": "Preview",
+ "groupId": "org.apache.camel",
+ "artifactId": "camel-state-store-caffeine",
+ "version": "4.23.0-SNAPSHOT"
+ }
+}
diff --git a/components/camel-state-store/camel-state-store-caffeine/src/main/java/org/apache/camel/component/statestore/caffeine/CaffeineStateStoreBackend.java b/components/camel-state-store/camel-state-store-caffeine/src/main/java/org/apache/camel/component/statestore/caffeine/CaffeineStateStoreBackend.java
new file mode 100644
index 000000000000..08a3316cd162
--- /dev/null
+++ b/components/camel-state-store/camel-state-store-caffeine/src/main/java/org/apache/camel/component/statestore/caffeine/CaffeineStateStoreBackend.java
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.statestore.caffeine;
+
+import java.time.Duration;
+import java.util.Set;
+
+import com.github.benmanes.caffeine.cache.Cache;
+import com.github.benmanes.caffeine.cache.Caffeine;
+import com.github.benmanes.caffeine.cache.Expiry;
+import org.apache.camel.component.statestore.StateStoreBackend;
+
+/**
+ * A {@link StateStoreBackend} implementation backed by Caffeine cache. Supports per-entry TTL using Caffeine's variable
+ * expiration.
+ *
+ * @since 4.23
+ */
+public class CaffeineStateStoreBackend implements StateStoreBackend {
+
+ private Cache<String, TimedValue> cache;
+ private int maximumSize = 10_000;
+
+ @Override
+ public Object put(String key, Object value, long ttlMillis) {
+ TimedValue previous = cache.asMap().put(key, new TimedValue(value, ttlMillis));
+ return previous != null ? previous.value() : null;
+ }
+
+ @Override
+ public Object get(String key) {
+ TimedValue entry = cache.getIfPresent(key);
+ return entry != null ? entry.value() : null;
+ }
+
+ @Override
+ public Object delete(String key) {
+ TimedValue previous = cache.asMap().remove(key);
+ return previous != null ? previous.value() : null;
+ }
+
+ @Override
+ public boolean contains(String key) {
+ return cache.getIfPresent(key) != null;
+ }
+
+ @Override
+ public Object putIfAbsent(String key, Object value, long ttlMillis) {
+ TimedValue newValue = new TimedValue(value, ttlMillis);
+ TimedValue existing = cache.asMap().putIfAbsent(key, newValue);
+ return existing != null ? existing.value() : null;
+ }
+
+ @Override
+ public int size() {
+ cache.cleanUp();
+ return (int) cache.estimatedSize();
+ }
+
+ @Override
+ public Set<String> keys() {
+ return Set.copyOf(cache.asMap().keySet());
+ }
+
+ @Override
+ public void clear() {
+ cache.invalidateAll();
+ }
+
+ @Override
+ public void start() {
+ if (cache != null) {
+ return;
+ }
+ cache = Caffeine.newBuilder()
+ .maximumSize(maximumSize)
+ .expireAfter(new Expiry<String, TimedValue>() {
+ @Override
+ public long expireAfterCreate(String key, TimedValue value, long currentTime) {
+ return value.ttlMillis() > 0
+ ? Duration.ofMillis(value.ttlMillis()).toNanos()
+ : Long.MAX_VALUE;
+ }
+
+ @Override
+ public long expireAfterUpdate(String key, TimedValue value, long currentTime, long currentDuration) {
+ return value.ttlMillis() > 0
+ ? Duration.ofMillis(value.ttlMillis()).toNanos()
+ : Long.MAX_VALUE;
+ }
+
+ @Override
+ public long expireAfterRead(String key, TimedValue value, long currentTime, long currentDuration) {
+ return currentDuration;
+ }
+ })
+ .build();
+ }
+
+ @Override
+ public void stop() {
+ if (cache != null) {
+ cache.invalidateAll();
+ cache.cleanUp();
+ cache = null;
+ }
+ }
+
+ public int getMaximumSize() {
+ return maximumSize;
+ }
+
+ public void setMaximumSize(int maximumSize) {
+ this.maximumSize = maximumSize;
+ }
+
+ private record TimedValue(Object value, long ttlMillis) {
+ }
+}
diff --git a/components/camel-state-store/camel-state-store-caffeine/src/test/java/org/apache/camel/component/statestore/caffeine/CaffeineStateStoreBackendTest.java b/components/camel-state-store/camel-state-store-caffeine/src/test/java/org/apache/camel/component/statestore/caffeine/CaffeineStateStoreBackendTest.java
new file mode 100644
index 000000000000..1fed0911079e
--- /dev/null
+++ b/components/camel-state-store/camel-state-store-caffeine/src/test/java/org/apache/camel/component/statestore/caffeine/CaffeineStateStoreBackendTest.java
@@ -0,0 +1,198 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.statestore.caffeine;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.BindToRegistry;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.statestore.StateStoreConstants;
+import org.apache.camel.component.statestore.StateStoreOperations;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+
+class CaffeineStateStoreBackendTest extends CamelTestSupport {
+
+ @BindToRegistry("caffeineBackend")
+ private final CaffeineStateStoreBackend backend = new CaffeineStateStoreBackend();
+
+ @Test
+ void testPutAndGet() {
+ template.requestBodyAndHeaders(
+ "direct:put", "hello",
+ Map.of(StateStoreConstants.KEY, "key1"));
+
+ Object result = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(result).isEqualTo("hello");
+ }
+
+ @Test
+ void testPutReturnsOldValue() {
+ template.requestBodyAndHeaders(
+ "direct:put", "first",
+ Map.of(StateStoreConstants.KEY, "key1"));
+
+ Object previous = template.requestBodyAndHeaders(
+ "direct:put", "second",
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(previous).isEqualTo("first");
+ }
+
+ @Test
+ void testDelete() {
+ template.requestBodyAndHeaders(
+ "direct:put", "value",
+ Map.of(StateStoreConstants.KEY, "key1"));
+
+ Object removed = template.requestBodyAndHeaders(
+ "direct:delete", null,
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(removed).isEqualTo("value");
+
+ Object result = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(result).isNull();
+ }
+
+ @Test
+ void testContains() {
+ template.requestBodyAndHeaders(
+ "direct:put", "value",
+ Map.of(StateStoreConstants.KEY, "key1"));
+
+ Object exists = template.requestBodyAndHeaders(
+ "direct:dynamic", null,
+ Map.of(StateStoreConstants.OPERATION, StateStoreOperations.contains,
+ StateStoreConstants.KEY, "key1"));
+ assertThat(exists).isEqualTo(true);
+ }
+
+ @Test
+ @SuppressWarnings("unchecked")
+ void testKeysAndSize() {
+ template.requestBodyAndHeaders(
+ "direct:put", "v1",
+ Map.of(StateStoreConstants.KEY, "a"));
+ template.requestBodyAndHeaders(
+ "direct:put", "v2",
+ Map.of(StateStoreConstants.KEY, "b"));
+
+ Set<String> keys = (Set<String>) template.requestBodyAndHeaders(
+ "direct:dynamic", null,
+ Map.of(StateStoreConstants.OPERATION, StateStoreOperations.keys));
+ assertThat(keys).containsExactlyInAnyOrder("a", "b");
+
+ Object size = template.requestBodyAndHeaders(
+ "direct:dynamic", null,
+ Map.of(StateStoreConstants.OPERATION, StateStoreOperations.size));
+ assertThat(size).isEqualTo(2);
+ }
+
+ @Test
+ void testPutIfAbsent() {
+ Object result = template.requestBodyAndHeaders(
+ "direct:dynamic", "first",
+ Map.of(StateStoreConstants.OPERATION, StateStoreOperations.putIfAbsent,
+ StateStoreConstants.KEY, "key1"));
+ assertThat(result).isNull();
+
+ result = template.requestBodyAndHeaders(
+ "direct:dynamic", "second",
+ Map.of(StateStoreConstants.OPERATION, StateStoreOperations.putIfAbsent,
+ StateStoreConstants.KEY, "key1"));
+ assertThat(result).isEqualTo("first");
+ }
+
+ @Test
+ void testClear() {
+ template.requestBodyAndHeaders(
+ "direct:put", "v1",
+ Map.of(StateStoreConstants.KEY, "a"));
+
+ template.requestBodyAndHeaders(
+ "direct:dynamic", null,
+ Map.of(StateStoreConstants.OPERATION, StateStoreOperations.clear));
+
+ Object result = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "a"));
+ assertThat(result).isNull();
+ }
+
+ @Test
+ void testTtlExpiry() {
+ template.requestBodyAndHeaders(
+ "direct:put-ttl", "expiring",
+ Map.of(StateStoreConstants.KEY, "ttlKey"));
+
+ Object result = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "ttlKey"));
+ assertThat(result).isEqualTo("expiring");
+
+ await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+ backend.keys(); // trigger Caffeine cleanup
+ Object expired = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "ttlKey"));
+ assertThat(expired).isNull();
+ });
+ }
+
+ @Test
+ void testPerMessageTtlHeader() {
+ template.requestBodyAndHeaders(
+ "direct:put", "expiring",
+ Map.of(StateStoreConstants.KEY, "ttlKey",
+ StateStoreConstants.TTL, 200L));
+
+ Object result = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "ttlKey"));
+ assertThat(result).isEqualTo("expiring");
+
+ await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+ backend.keys();
+ Object expired = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "ttlKey"));
+ assertThat(expired).isNull();
+ });
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:put").to("state-store:myStore?operation=put&backend=#caffeineBackend");
+ from("direct:put-ttl").to("state-store:myStore?operation=put&backend=#caffeineBackend&ttl=200");
+ from("direct:get").to("state-store:myStore?operation=get&backend=#caffeineBackend");
+ from("direct:delete").to("state-store:myStore?operation=delete&backend=#caffeineBackend");
+ from("direct:dynamic").to("state-store:myStore?backend=#caffeineBackend");
+ }
+ };
+ }
+}
diff --git a/components/camel-state-store/camel-state-store-caffeine/src/test/java/org/apache/camel/component/statestore/caffeine/CaffeineStateStorePropertiesTest.java b/components/camel-state-store/camel-state-store-caffeine/src/test/java/org/apache/camel/component/statestore/caffeine/CaffeineStateStorePropertiesTest.java
new file mode 100644
index 000000000000..18d760363ecb
--- /dev/null
+++ b/components/camel-state-store/camel-state-store-caffeine/src/test/java/org/apache/camel/component/statestore/caffeine/CaffeineStateStorePropertiesTest.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.statestore.caffeine;
+
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.statestore.StateStoreBackend;
+import org.apache.camel.component.statestore.StateStoreConstants;
+import org.apache.camel.test.main.junit5.CamelMainTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Tests that a Caffeine backend can be fully configured via properties (camel.beans.*) and auto-discovered without
+ * explicit backend=# reference on the endpoint.
+ */
+class CaffeineStateStorePropertiesTest extends CamelMainTestSupport {
+
+ @Override
+ protected Properties useOverridePropertiesWithPropertiesComponent() {
+ Properties props = new Properties();
+ props.setProperty("camel.beans.caffeineBackend",
+ "#class:" + CaffeineStateStoreBackend.class.getName());
+ props.setProperty("camel.beans.caffeineBackend.maximumSize", "5000");
+ return props;
+ }
+
+ @Test
+ void testBackendConfiguredViaProperties() {
+ // Verify the bean was created and configured
+ StateStoreBackend backend = context.getRegistry().lookupByNameAndType("caffeineBackend", StateStoreBackend.class);
+ assertThat(backend).isNotNull().isInstanceOf(CaffeineStateStoreBackend.class);
+ assertThat(((CaffeineStateStoreBackend) backend).getMaximumSize()).isEqualTo(5000);
+ }
+
+ @Test
+ void testAutoDiscoveryWithPropertiesConfiguredBackend() {
+ // No backend=#caffeineBackend in the URI — auto-discovery should find it
+ Object previous = template.requestBodyAndHeaders(
+ "direct:put", "hello",
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(previous).isNull();
+
+ Object result = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(result).isEqualTo("hello");
+ }
+
+ @Test
+ void testExplicitBeanReferenceWithPropertiesConfiguredBackend() {
+ // Explicit backend=#caffeineBackend — should also work
+ Object previous = template.requestBodyAndHeaders(
+ "direct:put-explicit", "world",
+ Map.of(StateStoreConstants.KEY, "key2"));
+ assertThat(previous).isNull();
+
+ Object result = template.requestBodyAndHeaders(
+ "direct:get-explicit", null,
+ Map.of(StateStoreConstants.KEY, "key2"));
+ assertThat(result).isEqualTo("world");
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ // Auto-discovery (no backend reference)
+ from("direct:put").to("state-store:myStore?operation=put");
+ from("direct:get").to("state-store:myStore?operation=get");
+ // Explicit bean reference
+ from("direct:put-explicit").to("state-store:explicitStore?operation=put&backend=#caffeineBackend");
+ from("direct:get-explicit").to("state-store:explicitStore?operation=get&backend=#caffeineBackend");
+ }
+ };
+ }
+}
diff --git a/components/camel-state-store/camel-state-store-infinispan/pom.xml b/components/camel-state-store/camel-state-store-infinispan/pom.xml
new file mode 100644
index 000000000000..724c59b84461
--- /dev/null
+++ b/components/camel-state-store/camel-state-store-infinispan/pom.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-state-store-parent</artifactId>
+ <version>4.23.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-state-store-infinispan</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Camel :: State Store :: Infinispan</name>
+ <description>Camel State Store backend using Infinispan remote (Hot Rod)</description>
+
+ <properties>
+ <firstVersion>4.23.0</firstVersion>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-state-store</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.infinispan</groupId>
+ <artifactId>infinispan-client-hotrod</artifactId>
+ <version>${infinispan-version}</version>
+ </dependency>
+
+ <!-- testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-main-junit5</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-infra-infinispan</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/components/camel-state-store/camel-state-store-infinispan/src/generated/resources/META-INF/services/org/apache/camel/other.properties b/components/camel-state-store/camel-state-store-infinispan/src/generated/resources/META-INF/services/org/apache/camel/other.properties
new file mode 100644
index 000000000000..f178128a44a5
--- /dev/null
+++ b/components/camel-state-store/camel-state-store-infinispan/src/generated/resources/META-INF/services/org/apache/camel/other.properties
@@ -0,0 +1,7 @@
+# Generated by camel build tools - do NOT edit this file!
+name=state-store-infinispan
+groupId=org.apache.camel
+artifactId=camel-state-store-infinispan
+version=4.23.0-SNAPSHOT
+projectName=Camel :: State Store :: Infinispan
+projectDescription=Camel State Store backend using Infinispan remote (Hot Rod)
diff --git a/components/camel-state-store/camel-state-store-infinispan/src/generated/resources/state-store-infinispan.json b/components/camel-state-store/camel-state-store-infinispan/src/generated/resources/state-store-infinispan.json
new file mode 100644
index 000000000000..a047688f0bcf
--- /dev/null
+++ b/components/camel-state-store/camel-state-store-infinispan/src/generated/resources/state-store-infinispan.json
@@ -0,0 +1,14 @@
+{
+ "other": {
+ "kind": "other",
+ "name": "state-store-infinispan",
+ "title": "State Store Infinispan",
+ "description": "Camel State Store backend using Infinispan remote (Hot Rod)",
+ "deprecated": false,
+ "firstVersion": "4.23.0",
+ "supportLevel": "Preview",
+ "groupId": "org.apache.camel",
+ "artifactId": "camel-state-store-infinispan",
+ "version": "4.23.0-SNAPSHOT"
+ }
+}
diff --git a/components/camel-state-store/camel-state-store-infinispan/src/main/java/org/apache/camel/component/statestore/infinispan/InfinispanStateStoreBackend.java b/components/camel-state-store/camel-state-store-infinispan/src/main/java/org/apache/camel/component/statestore/infinispan/InfinispanStateStoreBackend.java
new file mode 100644
index 000000000000..150315a4b64f
--- /dev/null
+++ b/components/camel-state-store/camel-state-store-infinispan/src/main/java/org/apache/camel/component/statestore/infinispan/InfinispanStateStoreBackend.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.statestore.infinispan;
+
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.component.statestore.StateStoreBackend;
+import org.infinispan.client.hotrod.RemoteCache;
+import org.infinispan.client.hotrod.RemoteCacheManager;
+import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
+
+/**
+ * A {@link StateStoreBackend} implementation backed by Infinispan remote (Hot Rod). Supports per-entry TTL via
+ * Infinispan's lifespan parameter.
+ *
+ * @since 4.23
+ */
+public class InfinispanStateStoreBackend implements StateStoreBackend {
+
+ private RemoteCacheManager cacheManager;
+ private RemoteCache<String, Object> cache;
+ private String hosts = "localhost:11222";
+ private String cacheName = "camel-state-store";
+ private boolean managedCacheManager;
+
+ @Override
+ public Object put(String key, Object value, long ttlMillis) {
+ if (ttlMillis > 0) {
+ return cache.put(key, value, ttlMillis, TimeUnit.MILLISECONDS);
+ }
+ return cache.put(key, value);
+ }
+
+ @Override
+ public Object putIfAbsent(String key, Object value, long ttlMillis) {
+ if (ttlMillis > 0) {
+ return cache.putIfAbsent(key, value, ttlMillis, TimeUnit.MILLISECONDS);
+ }
+ return cache.putIfAbsent(key, value);
+ }
+
+ @Override
+ public Object get(String key) {
+ return cache.get(key);
+ }
+
+ @Override
+ public Object delete(String key) {
+ return cache.remove(key);
+ }
+
+ @Override
+ public boolean contains(String key) {
+ return cache.containsKey(key);
+ }
+
+ @Override
+ public Set<String> keys() {
+ return Set.copyOf(cache.keySet());
+ }
+
+ @Override
+ public int size() {
+ return cache.size();
+ }
+
+ @Override
+ public void clear() {
+ cache.clear();
+ }
+
+ @Override
+ public void start() {
+ if (cache != null) {
+ return;
+ }
+ if (cacheManager == null) {
+ ConfigurationBuilder builder = new ConfigurationBuilder();
+ builder.addServers(hosts);
+ builder.forceReturnValues(true);
+ cacheManager = new RemoteCacheManager(builder.build(), true);
+ managedCacheManager = true;
+ }
+ cache = cacheManager.administration().getOrCreateCache(cacheName, (String) null);
+ }
+
+ @Override
+ public void stop() {
+ cache = null;
+ if (managedCacheManager && cacheManager != null) {
+ cacheManager.stop();
+ cacheManager = null;
+ managedCacheManager = false;
+ }
+ }
+
+ public RemoteCacheManager getCacheManager() {
+ return cacheManager;
+ }
+
+ public void setCacheManager(RemoteCacheManager cacheManager) {
+ this.cacheManager = cacheManager;
+ }
+
+ public String getHosts() {
+ return hosts;
+ }
+
+ public void setHosts(String hosts) {
+ this.hosts = hosts;
+ }
+
+ public String getCacheName() {
+ return cacheName;
+ }
+
+ public void setCacheName(String cacheName) {
+ this.cacheName = cacheName;
+ }
+}
diff --git a/components/camel-state-store/camel-state-store-infinispan/src/test/java/org/apache/camel/component/statestore/infinispan/InfinispanStateStoreBackendIT.java b/components/camel-state-store/camel-state-store-infinispan/src/test/java/org/apache/camel/component/statestore/infinispan/InfinispanStateStoreBackendIT.java
new file mode 100644
index 000000000000..c4712721f7f2
--- /dev/null
+++ b/components/camel-state-store/camel-state-store-infinispan/src/test/java/org/apache/camel/component/statestore/infinispan/InfinispanStateStoreBackendIT.java
@@ -0,0 +1,240 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.statestore.infinispan;
+
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.BindToRegistry;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.statestore.StateStoreConstants;
+import org.apache.camel.component.statestore.StateStoreOperations;
+import org.apache.camel.test.infra.infinispan.services.InfinispanService;
+import org.apache.camel.test.infra.infinispan.services.InfinispanServiceFactory;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.infinispan.client.hotrod.RemoteCacheManager;
+import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+
+class InfinispanStateStoreBackendIT extends CamelTestSupport {
+
+ private static final boolean IS_MAC_OS = System.getProperty("os.name", "").startsWith("Mac");
+
+ @RegisterExtension
+ static InfinispanService service = InfinispanServiceFactory.createSingletonInfinispanService();
+
+ private InfinispanStateStoreBackend backend;
+ private RemoteCacheManager testCacheManager;
+
+ @AfterEach
+ void cleanUp() {
+ if (testCacheManager != null) {
+ testCacheManager.stop();
+ testCacheManager = null;
+ }
+ }
+
+ @BeforeEach
+ void clearCache() {
+ if (backend != null) {
+ template.requestBodyAndHeaders("direct:op", (Object) null,
+ Map.of(StateStoreConstants.OPERATION, StateStoreOperations.clear));
+ }
+ }
+
+ @BindToRegistry("infinispanBackend")
+ public InfinispanStateStoreBackend createBackend() {
+ backend = new InfinispanStateStoreBackend();
+
+ ConfigurationBuilder builder = new ConfigurationBuilder();
+ builder.forceReturnValues(true);
+ builder.addServers(service.host() + ":" + service.port());
+ if (service.username() != null) {
+ builder.security().authentication()
+ .username(service.username())
+ .password(service.password())
+ .saslMechanism("SCRAM-SHA-512")
+ .realm("default")
+ .serverName("infinispan");
+ }
+ if (IS_MAC_OS) {
+ Properties properties = new Properties();
+ properties.put("infinispan.client.hotrod.client_intelligence", "BASIC");
+ builder.withProperties(properties);
+ }
+ testCacheManager = new RemoteCacheManager(builder.build(), true);
+ backend.setCacheManager(testCacheManager);
+ backend.setCacheName("state-store-test");
+ return backend;
+ }
+
+ @Test
+ void testPutAndGet() {
+ template.requestBodyAndHeaders(
+ "direct:put", "hello",
+ Map.of(StateStoreConstants.KEY, "key1"));
+
+ Object result = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(result).isEqualTo("hello");
+ }
+
+ @Test
+ void testPutReturnsOldValue() {
+ template.requestBodyAndHeaders(
+ "direct:put", "first",
+ Map.of(StateStoreConstants.KEY, "key1"));
+
+ Object previous = template.requestBodyAndHeaders(
+ "direct:put", "second",
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(previous).isEqualTo("first");
+ }
+
+ @Test
+ void testDelete() {
+ template.requestBodyAndHeaders(
+ "direct:put", "value",
+ Map.of(StateStoreConstants.KEY, "key1"));
+
+ Object removed = template.requestBodyAndHeaders(
+ "direct:delete", null,
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(removed).isEqualTo("value");
+ }
+
+ @Test
+ void testContains() {
+ template.requestBodyAndHeaders(
+ "direct:put", "value",
+ Map.of(StateStoreConstants.KEY, "key1"));
+
+ Object exists = template.requestBodyAndHeaders(
+ "direct:op", null,
+ Map.of(StateStoreConstants.OPERATION, StateStoreOperations.contains,
+ StateStoreConstants.KEY, "key1"));
+ assertThat(exists).isEqualTo(true);
+
+ Object notExists = template.requestBodyAndHeaders(
+ "direct:op", null,
+ Map.of(StateStoreConstants.OPERATION, StateStoreOperations.contains,
+ StateStoreConstants.KEY, "missing"));
+ assertThat(notExists).isEqualTo(false);
+ }
+
+ @Test
+ void testClear() {
+ template.requestBodyAndHeaders(
+ "direct:put", "v1",
+ Map.of(StateStoreConstants.KEY, "a"));
+
+ template.requestBodyAndHeaders(
+ "direct:op", null,
+ Map.of(StateStoreConstants.OPERATION, StateStoreOperations.clear));
+
+ Object result = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "a"));
+ assertThat(result).isNull();
+ }
+
+ @Test
+ void testDeleteNonExistentKey() {
+ Object removed = template.requestBodyAndHeaders(
+ "direct:delete", null,
+ Map.of(StateStoreConstants.KEY, "no-such-key"));
+ assertThat(removed).isNull();
+ }
+
+ @Test
+ @SuppressWarnings("unchecked")
+ void testKeysAndSize() {
+ template.requestBodyAndHeaders(
+ "direct:put", "v1",
+ Map.of(StateStoreConstants.KEY, "a"));
+ template.requestBodyAndHeaders(
+ "direct:put", "v2",
+ Map.of(StateStoreConstants.KEY, "b"));
+
+ Set<String> keys = (Set<String>) template.requestBodyAndHeaders(
+ "direct:op", null,
+ Map.of(StateStoreConstants.OPERATION, StateStoreOperations.keys));
+ assertThat(keys).containsExactlyInAnyOrder("a", "b");
+
+ Object size = template.requestBodyAndHeaders(
+ "direct:op", null,
+ Map.of(StateStoreConstants.OPERATION, StateStoreOperations.size));
+ assertThat(size).isEqualTo(2);
+ }
+
+ @Test
+ void testPutIfAbsent() {
+ Object result = template.requestBodyAndHeaders(
+ "direct:op", "first",
+ Map.of(StateStoreConstants.OPERATION, StateStoreOperations.putIfAbsent,
+ StateStoreConstants.KEY, "key1"));
+ assertThat(result).isNull();
+
+ result = template.requestBodyAndHeaders(
+ "direct:op", "second",
+ Map.of(StateStoreConstants.OPERATION, StateStoreOperations.putIfAbsent,
+ StateStoreConstants.KEY, "key1"));
+ assertThat(result).isEqualTo("first");
+ }
+
+ @Test
+ void testTtlExpiry() {
+ template.requestBodyAndHeaders(
+ "direct:put", "expiring",
+ Map.of(StateStoreConstants.KEY, "ttlKey",
+ StateStoreConstants.TTL, 500L));
+
+ Object result = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "ttlKey"));
+ assertThat(result).isEqualTo("expiring");
+
+ await().atMost(10, TimeUnit.SECONDS).untilAsserted(() -> {
+ Object expired = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "ttlKey"));
+ assertThat(expired).isNull();
+ });
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:put").to("state-store:ispnStore?operation=put&backend=#infinispanBackend");
+ from("direct:get").to("state-store:ispnStore?operation=get&backend=#infinispanBackend");
+ from("direct:delete").to("state-store:ispnStore?operation=delete&backend=#infinispanBackend");
+ from("direct:op").to("state-store:ispnStore?backend=#infinispanBackend");
+ }
+ };
+ }
+}
diff --git a/components/camel-state-store/camel-state-store-infinispan/src/test/java/org/apache/camel/component/statestore/infinispan/InfinispanStateStorePropertiesIT.java b/components/camel-state-store/camel-state-store-infinispan/src/test/java/org/apache/camel/component/statestore/infinispan/InfinispanStateStorePropertiesIT.java
new file mode 100644
index 000000000000..b10e74feec11
--- /dev/null
+++ b/components/camel-state-store/camel-state-store-infinispan/src/test/java/org/apache/camel/component/statestore/infinispan/InfinispanStateStorePropertiesIT.java
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.statestore.infinispan;
+
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.statestore.StateStoreBackend;
+import org.apache.camel.component.statestore.StateStoreConstants;
+import org.apache.camel.spi.Registry;
+import org.apache.camel.test.infra.infinispan.services.InfinispanService;
+import org.apache.camel.test.infra.infinispan.services.InfinispanServiceFactory;
+import org.apache.camel.test.main.junit5.CamelMainTestSupport;
+import org.infinispan.client.hotrod.RemoteCacheManager;
+import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Tests that an Infinispan backend can be configured via properties (camel.beans.*) and auto-discovered. The backend is
+ * created via properties but the {@link RemoteCacheManager} is injected programmatically since it requires
+ * authentication and platform-specific configuration that cannot be expressed as simple properties.
+ */
+class InfinispanStateStorePropertiesIT extends CamelMainTestSupport {
+
+ private static final boolean IS_MAC_OS = System.getProperty("os.name", "").startsWith("Mac");
+
+ @RegisterExtension
+ static InfinispanService service = InfinispanServiceFactory.createSingletonInfinispanService();
+
+ private RemoteCacheManager testCacheManager;
+
+ @AfterEach
+ void cleanUp() {
+ if (testCacheManager != null) {
+ testCacheManager.stop();
+ testCacheManager = null;
+ }
+ }
+
+ @Override
+ protected Properties useOverridePropertiesWithPropertiesComponent() {
+ Properties props = new Properties();
+ props.setProperty("camel.beans.infinispanBackend",
+ "#class:" + InfinispanStateStoreBackend.class.getName());
+ props.setProperty("camel.beans.infinispanBackend.cacheName", "state-store-props-test");
+ return props;
+ }
+
+ @Override
+ protected void bindToRegistry(Registry registry) throws Exception {
+ super.bindToRegistry(registry);
+ // Inject a pre-configured RemoteCacheManager into the property-created backend.
+ // Authentication and platform-specific settings require programmatic configuration.
+ InfinispanStateStoreBackend backend
+ = registry.lookupByNameAndType("infinispanBackend", InfinispanStateStoreBackend.class);
+ if (backend != null) {
+ backend.setCacheManager(createCacheManager());
+ }
+ }
+
+ private RemoteCacheManager createCacheManager() {
+ ConfigurationBuilder builder = new ConfigurationBuilder();
+ builder.forceReturnValues(true);
+ builder.addServers(service.host() + ":" + service.port());
+ if (service.username() != null) {
+ builder.security().authentication()
+ .username(service.username())
+ .password(service.password())
+ .saslMechanism("SCRAM-SHA-512")
+ .realm("default")
+ .serverName("infinispan");
+ }
+ if (IS_MAC_OS) {
+ Properties properties = new Properties();
+ properties.put("infinispan.client.hotrod.client_intelligence", "BASIC");
+ builder.withProperties(properties);
+ }
+ testCacheManager = new RemoteCacheManager(builder.build(), true);
+ return testCacheManager;
+ }
+
+ @Test
+ void testBackendConfiguredViaProperties() {
+ StateStoreBackend backend = context.getRegistry().lookupByNameAndType("infinispanBackend", StateStoreBackend.class);
+ assertThat(backend).isNotNull().isInstanceOf(InfinispanStateStoreBackend.class);
+ assertThat(((InfinispanStateStoreBackend) backend).getCacheName()).isEqualTo("state-store-props-test");
+ }
+
+ @Test
+ void testAutoDiscoveryPutAndGet() {
+ // No backend=#infinispanBackend in the URI — auto-discovery should find it
+ Object previous = template.requestBodyAndHeaders(
+ "direct:put", "hello",
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(previous).isNull();
+
+ Object result = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(result).isEqualTo("hello");
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ // No backend=# reference — relies on auto-discovery
+ from("direct:put").to("state-store:ispnStore?operation=put");
+ from("direct:get").to("state-store:ispnStore?operation=get");
+ }
+ };
+ }
+}
diff --git a/components/camel-state-store/camel-state-store-redis/pom.xml b/components/camel-state-store/camel-state-store-redis/pom.xml
new file mode 100644
index 000000000000..bac53dba3784
--- /dev/null
+++ b/components/camel-state-store/camel-state-store-redis/pom.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-state-store-parent</artifactId>
+ <version>4.23.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-state-store-redis</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Camel :: State Store :: Redis</name>
+ <description>Camel State Store backend using Redisson (Redis)</description>
+
+ <properties>
+ <firstVersion>4.23.0</firstVersion>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-state-store</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.redisson</groupId>
+ <artifactId>redisson</artifactId>
+ <version>${redisson-version}</version>
+ </dependency>
+
+ <!-- testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-main-junit5</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-infra-redis</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/components/camel-state-store/camel-state-store-redis/src/generated/resources/META-INF/services/org/apache/camel/other.properties b/components/camel-state-store/camel-state-store-redis/src/generated/resources/META-INF/services/org/apache/camel/other.properties
new file mode 100644
index 000000000000..bd0bb6ee55ee
--- /dev/null
+++ b/components/camel-state-store/camel-state-store-redis/src/generated/resources/META-INF/services/org/apache/camel/other.properties
@@ -0,0 +1,7 @@
+# Generated by camel build tools - do NOT edit this file!
+name=state-store-redis
+groupId=org.apache.camel
+artifactId=camel-state-store-redis
+version=4.23.0-SNAPSHOT
+projectName=Camel :: State Store :: Redis
+projectDescription=Camel State Store backend using Redisson (Redis)
diff --git a/components/camel-state-store/camel-state-store-redis/src/generated/resources/state-store-redis.json b/components/camel-state-store/camel-state-store-redis/src/generated/resources/state-store-redis.json
new file mode 100644
index 000000000000..20889cda5326
--- /dev/null
+++ b/components/camel-state-store/camel-state-store-redis/src/generated/resources/state-store-redis.json
@@ -0,0 +1,14 @@
+{
+ "other": {
+ "kind": "other",
+ "name": "state-store-redis",
+ "title": "State Store Redis",
+ "description": "Camel State Store backend using Redisson (Redis)",
+ "deprecated": false,
+ "firstVersion": "4.23.0",
+ "supportLevel": "Preview",
+ "groupId": "org.apache.camel",
+ "artifactId": "camel-state-store-redis",
+ "version": "4.23.0-SNAPSHOT"
+ }
+}
diff --git a/components/camel-state-store/camel-state-store-redis/src/main/java/org/apache/camel/component/statestore/redis/RedisStateStoreBackend.java b/components/camel-state-store/camel-state-store-redis/src/main/java/org/apache/camel/component/statestore/redis/RedisStateStoreBackend.java
new file mode 100644
index 000000000000..861e08db92ab
--- /dev/null
+++ b/components/camel-state-store/camel-state-store-redis/src/main/java/org/apache/camel/component/statestore/redis/RedisStateStoreBackend.java
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.statestore.redis;
+
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.component.statestore.StateStoreBackend;
+import org.redisson.Redisson;
+import org.redisson.api.RMapCache;
+import org.redisson.api.RedissonClient;
+import org.redisson.config.Config;
+
+/**
+ * A {@link StateStoreBackend} implementation backed by Redis using Redisson. Uses {@link RMapCache} for per-entry TTL
+ * support.
+ *
+ * @since 4.23
+ */
+public class RedisStateStoreBackend implements StateStoreBackend {
+
+ private RedissonClient redisson;
+ private RMapCache<String, Object> mapCache;
+ private String redisUrl = "redis://localhost:6379";
+ private String mapName = "camel-state-store";
+ private boolean managedRedisson;
+
+ @Override
+ public Object put(String key, Object value, long ttlMillis) {
+ if (ttlMillis > 0) {
+ return mapCache.put(key, value, ttlMillis, TimeUnit.MILLISECONDS);
+ }
+ return mapCache.put(key, value);
+ }
+
+ @Override
+ public Object putIfAbsent(String key, Object value, long ttlMillis) {
+ if (ttlMillis > 0) {
+ return mapCache.putIfAbsent(key, value, ttlMillis, TimeUnit.MILLISECONDS);
+ }
+ return mapCache.putIfAbsent(key, value);
+ }
+
+ @Override
+ public Object get(String key) {
+ return mapCache.get(key);
+ }
+
+ @Override
+ public Object delete(String key) {
+ return mapCache.remove(key);
+ }
+
+ @Override
+ public boolean contains(String key) {
+ return mapCache.containsKey(key);
+ }
+
+ @Override
+ public Set<String> keys() {
+ return Set.copyOf(mapCache.keySet());
+ }
+
+ @Override
+ public int size() {
+ return mapCache.size();
+ }
+
+ @Override
+ public void clear() {
+ mapCache.clear();
+ }
+
+ @Override
+ public void start() {
+ if (redisson == null) {
+ Config config = new Config();
+ config.useSingleServer().setAddress(redisUrl);
+ redisson = Redisson.create(config);
+ managedRedisson = true;
+ }
+ mapCache = redisson.getMapCache(mapName);
+ }
+
+ @Override
+ public void stop() {
+ mapCache = null;
+ if (managedRedisson && redisson != null) {
+ redisson.shutdown();
+ redisson = null;
+ managedRedisson = false;
+ }
+ }
+
+ public RedissonClient getRedisson() {
+ return redisson;
+ }
+
+ public void setRedisson(RedissonClient redisson) {
+ this.redisson = redisson;
+ }
+
+ public String getRedisUrl() {
+ return redisUrl;
+ }
+
+ public void setRedisUrl(String redisUrl) {
+ this.redisUrl = redisUrl;
+ }
+
+ public String getMapName() {
+ return mapName;
+ }
+
+ public void setMapName(String mapName) {
+ this.mapName = mapName;
+ }
+}
diff --git a/components/camel-state-store/camel-state-store-redis/src/test/java/org/apache/camel/component/statestore/redis/RedisStateStoreBackendIT.java b/components/camel-state-store/camel-state-store-redis/src/test/java/org/apache/camel/component/statestore/redis/RedisStateStoreBackendIT.java
new file mode 100644
index 000000000000..98200385ccfe
--- /dev/null
+++ b/components/camel-state-store/camel-state-store-redis/src/test/java/org/apache/camel/component/statestore/redis/RedisStateStoreBackendIT.java
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.statestore.redis;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.BindToRegistry;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.statestore.StateStoreConstants;
+import org.apache.camel.component.statestore.StateStoreOperations;
+import org.apache.camel.test.infra.redis.services.RedisService;
+import org.apache.camel.test.infra.redis.services.RedisServiceFactory;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+
+class RedisStateStoreBackendIT extends CamelTestSupport {
+
+ @RegisterExtension
+ static RedisService service = RedisServiceFactory.createService();
+
+ private RedisStateStoreBackend backend;
+
+ @BindToRegistry("redisBackend")
+ public RedisStateStoreBackend createBackend() {
+ backend = new RedisStateStoreBackend();
+ backend.setRedisUrl("redis://" + service.getServiceAddress());
+ backend.setMapName("test-state-store-" + System.nanoTime());
+ return backend;
+ }
+
+ @Test
+ void testPutAndGet() {
+ template.requestBodyAndHeaders(
+ "direct:put", "hello",
+ Map.of(StateStoreConstants.KEY, "key1"));
+
+ Object result = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(result).isEqualTo("hello");
+ }
+
+ @Test
+ void testPutReturnsOldValue() {
+ template.requestBodyAndHeaders(
+ "direct:put", "first",
+ Map.of(StateStoreConstants.KEY, "key1"));
+
+ Object previous = template.requestBodyAndHeaders(
+ "direct:put", "second",
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(previous).isEqualTo("first");
+ }
+
+ @Test
+ void testDelete() {
+ template.requestBodyAndHeaders(
+ "direct:put", "value",
+ Map.of(StateStoreConstants.KEY, "key1"));
+
+ Object removed = template.requestBodyAndHeaders(
+ "direct:delete", null,
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(removed).isEqualTo("value");
+
+ // verify key is gone
+ Object result = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(result).isNull();
+ }
+
+ @Test
+ void testDeleteNonExistentKey() {
+ Object removed = template.requestBodyAndHeaders(
+ "direct:delete", null,
+ Map.of(StateStoreConstants.KEY, "no-such-key"));
+ assertThat(removed).isNull();
+ }
+
+ @Test
+ void testContains() {
+ template.requestBodyAndHeaders(
+ "direct:put", "value",
+ Map.of(StateStoreConstants.KEY, "key1"));
+
+ Object exists = template.requestBodyAndHeaders(
+ "direct:op", null,
+ Map.of(StateStoreConstants.OPERATION, StateStoreOperations.contains,
+ StateStoreConstants.KEY, "key1"));
+ assertThat(exists).isEqualTo(true);
+
+ Object notExists = template.requestBodyAndHeaders(
+ "direct:op", null,
+ Map.of(StateStoreConstants.OPERATION, StateStoreOperations.contains,
+ StateStoreConstants.KEY, "missing"));
+ assertThat(notExists).isEqualTo(false);
+ }
+
+ @Test
+ @SuppressWarnings("unchecked")
+ void testKeysAndSize() {
+ template.requestBodyAndHeaders(
+ "direct:put", "v1",
+ Map.of(StateStoreConstants.KEY, "a"));
+ template.requestBodyAndHeaders(
+ "direct:put", "v2",
+ Map.of(StateStoreConstants.KEY, "b"));
+
+ Set<String> keys = (Set<String>) template.requestBodyAndHeaders(
+ "direct:op", null,
+ Map.of(StateStoreConstants.OPERATION, StateStoreOperations.keys));
+ assertThat(keys).containsExactlyInAnyOrder("a", "b");
+
+ Object size = template.requestBodyAndHeaders(
+ "direct:op", null,
+ Map.of(StateStoreConstants.OPERATION, StateStoreOperations.size));
+ assertThat(size).isEqualTo(2);
+ }
+
+ @Test
+ void testPutIfAbsent() {
+ Object result = template.requestBodyAndHeaders(
+ "direct:op", "first",
+ Map.of(StateStoreConstants.OPERATION, StateStoreOperations.putIfAbsent,
+ StateStoreConstants.KEY, "key1"));
+ assertThat(result).isNull();
+
+ result = template.requestBodyAndHeaders(
+ "direct:op", "second",
+ Map.of(StateStoreConstants.OPERATION, StateStoreOperations.putIfAbsent,
+ StateStoreConstants.KEY, "key1"));
+ assertThat(result).isEqualTo("first");
+ }
+
+ @Test
+ void testClear() {
+ template.requestBodyAndHeaders(
+ "direct:put", "v1",
+ Map.of(StateStoreConstants.KEY, "a"));
+
+ template.requestBodyAndHeaders(
+ "direct:op", null,
+ Map.of(StateStoreConstants.OPERATION, StateStoreOperations.clear));
+
+ Object result = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "a"));
+ assertThat(result).isNull();
+ }
+
+ @Test
+ void testTtlExpiry() {
+ template.requestBodyAndHeaders(
+ "direct:put", "expiring",
+ Map.of(StateStoreConstants.KEY, "ttlKey",
+ StateStoreConstants.TTL, 500L));
+
+ Object result = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "ttlKey"));
+ assertThat(result).isEqualTo("expiring");
+
+ await().atMost(10, TimeUnit.SECONDS).untilAsserted(() -> {
+ Object expired = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "ttlKey"));
+ assertThat(expired).isNull();
+ });
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:put").to("state-store:redisStore?operation=put&backend=#redisBackend");
+ from("direct:get").to("state-store:redisStore?operation=get&backend=#redisBackend");
+ from("direct:delete").to("state-store:redisStore?operation=delete&backend=#redisBackend");
+ from("direct:op").to("state-store:redisStore?backend=#redisBackend");
+ }
+ };
+ }
+}
diff --git a/components/camel-state-store/camel-state-store-redis/src/test/java/org/apache/camel/component/statestore/redis/RedisStateStorePropertiesIT.java b/components/camel-state-store/camel-state-store-redis/src/test/java/org/apache/camel/component/statestore/redis/RedisStateStorePropertiesIT.java
new file mode 100644
index 000000000000..07b849e47938
--- /dev/null
+++ b/components/camel-state-store/camel-state-store-redis/src/test/java/org/apache/camel/component/statestore/redis/RedisStateStorePropertiesIT.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.statestore.redis;
+
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.statestore.StateStoreBackend;
+import org.apache.camel.component.statestore.StateStoreConstants;
+import org.apache.camel.test.infra.redis.services.RedisService;
+import org.apache.camel.test.infra.redis.services.RedisServiceFactory;
+import org.apache.camel.test.main.junit5.CamelMainTestSupport;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Tests that a Redis backend can be fully configured via properties (camel.beans.*) and auto-discovered without
+ * explicit backend=# reference on the endpoint.
+ */
+class RedisStateStorePropertiesIT extends CamelMainTestSupport {
+
+ @RegisterExtension
+ static RedisService service = RedisServiceFactory.createService();
+
+ @Override
+ protected Properties useOverridePropertiesWithPropertiesComponent() {
+ Properties props = new Properties();
+ props.setProperty("camel.beans.redisBackend",
+ "#class:" + RedisStateStoreBackend.class.getName());
+ props.setProperty("camel.beans.redisBackend.redisUrl", "redis://" + service.getServiceAddress());
+ props.setProperty("camel.beans.redisBackend.mapName", "test-props-" + System.nanoTime());
+ return props;
+ }
+
+ @Test
+ void testBackendConfiguredViaProperties() {
+ StateStoreBackend backend = context.getRegistry().lookupByNameAndType("redisBackend", StateStoreBackend.class);
+ assertThat(backend).isNotNull().isInstanceOf(RedisStateStoreBackend.class);
+ }
+
+ @Test
+ void testAutoDiscoveryPutAndGet() {
+ // No backend=#redisBackend in the URI — auto-discovery should find it
+ Object previous = template.requestBodyAndHeaders(
+ "direct:put", "hello",
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(previous).isNull();
+
+ Object result = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(result).isEqualTo("hello");
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ // No backend=# reference — relies on auto-discovery
+ from("direct:put").to("state-store:redisStore?operation=put");
+ from("direct:get").to("state-store:redisStore?operation=get");
+ }
+ };
+ }
+}
diff --git a/components/camel-state-store/camel-state-store/pom.xml b/components/camel-state-store/camel-state-store/pom.xml
new file mode 100644
index 000000000000..e6b15973ee33
--- /dev/null
+++ b/components/camel-state-store/camel-state-store/pom.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-state-store-parent</artifactId>
+ <version>4.23.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-state-store</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Camel :: State Store</name>
+
+ <properties>
+ <firstVersion>4.23.0</firstVersion>
+ </properties>
+ <description>Camel State Store component for pluggable key-value store operations</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-support</artifactId>
+ </dependency>
+
+ <!-- testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-main-junit5</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-mock</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/components/camel-state-store/camel-state-store/src/generated/java/org/apache/camel/component/statestore/StateStoreComponentConfigurer.java b/components/camel-state-store/camel-state-store/src/generated/java/org/apache/camel/component/statestore/StateStoreComponentConfigurer.java
new file mode 100644
index 000000000000..fa7fc5815700
--- /dev/null
+++ b/components/camel-state-store/camel-state-store/src/generated/java/org/apache/camel/component/statestore/StateStoreComponentConfigurer.java
@@ -0,0 +1,57 @@
+/* Generated by camel build tools - do NOT edit this file! */
+package org.apache.camel.component.statestore;
+
+import javax.annotation.processing.Generated;
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spi.ExtendedPropertyConfigurerGetter;
+import org.apache.camel.spi.PropertyConfigurerGetter;
+import org.apache.camel.spi.ConfigurerStrategy;
+import org.apache.camel.spi.GeneratedPropertyConfigurer;
+import org.apache.camel.util.CaseInsensitiveMap;
+import org.apache.camel.support.component.PropertyConfigurerSupport;
+
+/**
+ * Generated by camel build tools - do NOT edit this file!
+ */
+@Generated("org.apache.camel.maven.packaging.EndpointSchemaGeneratorMojo")
+@SuppressWarnings("unchecked")
+public class StateStoreComponentConfigurer extends PropertyConfigurerSupport implements GeneratedPropertyConfigurer, PropertyConfigurerGetter {
+
+ @Override
+ public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) {
+ StateStoreComponent target = (StateStoreComponent) obj;
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "autowiredenabled":
+ case "autowiredEnabled": target.setAutowiredEnabled(property(camelContext, boolean.class, value)); return true;
+ case "lazystartproducer":
+ case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true;
+ default: return false;
+ }
+ }
+
+ @Override
+ public Class<?> getOptionType(String name, boolean ignoreCase) {
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "autowiredenabled":
+ case "autowiredEnabled": return boolean.class;
+ case "lazystartproducer":
+ case "lazyStartProducer": return boolean.class;
+ default: return null;
+ }
+ }
+
+ @Override
+ public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
+ StateStoreComponent target = (StateStoreComponent) obj;
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "autowiredenabled":
+ case "autowiredEnabled": return target.isAutowiredEnabled();
+ case "lazystartproducer":
+ case "lazyStartProducer": return target.isLazyStartProducer();
+ default: return null;
+ }
+ }
+}
+
diff --git a/components/camel-state-store/camel-state-store/src/generated/java/org/apache/camel/component/statestore/StateStoreEndpointConfigurer.java b/components/camel-state-store/camel-state-store/src/generated/java/org/apache/camel/component/statestore/StateStoreEndpointConfigurer.java
new file mode 100644
index 000000000000..a9c3c59a868f
--- /dev/null
+++ b/components/camel-state-store/camel-state-store/src/generated/java/org/apache/camel/component/statestore/StateStoreEndpointConfigurer.java
@@ -0,0 +1,60 @@
+/* Generated by camel build tools - do NOT edit this file! */
+package org.apache.camel.component.statestore;
+
+import javax.annotation.processing.Generated;
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spi.ExtendedPropertyConfigurerGetter;
+import org.apache.camel.spi.PropertyConfigurerGetter;
+import org.apache.camel.spi.ConfigurerStrategy;
+import org.apache.camel.spi.GeneratedPropertyConfigurer;
+import org.apache.camel.util.CaseInsensitiveMap;
+import org.apache.camel.support.component.PropertyConfigurerSupport;
+
+/**
+ * Generated by camel build tools - do NOT edit this file!
+ */
+@Generated("org.apache.camel.maven.packaging.EndpointSchemaGeneratorMojo")
+@SuppressWarnings("unchecked")
+public class StateStoreEndpointConfigurer extends PropertyConfigurerSupport implements GeneratedPropertyConfigurer, PropertyConfigurerGetter {
+
+ @Override
+ public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) {
+ StateStoreEndpoint target = (StateStoreEndpoint) obj;
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "backend": target.setBackend(property(camelContext, org.apache.camel.component.statestore.StateStoreBackend.class, value)); return true;
+ case "lazystartproducer":
+ case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true;
+ case "operation": target.setOperation(property(camelContext, org.apache.camel.component.statestore.StateStoreOperations.class, value)); return true;
+ case "ttl": target.setTtl(property(camelContext, long.class, value)); return true;
+ default: return false;
+ }
+ }
+
+ @Override
+ public Class<?> getOptionType(String name, boolean ignoreCase) {
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "backend": return org.apache.camel.component.statestore.StateStoreBackend.class;
+ case "lazystartproducer":
+ case "lazyStartProducer": return boolean.class;
+ case "operation": return org.apache.camel.component.statestore.StateStoreOperations.class;
+ case "ttl": return long.class;
+ default: return null;
+ }
+ }
+
+ @Override
+ public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
+ StateStoreEndpoint target = (StateStoreEndpoint) obj;
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "backend": return target.getBackend();
+ case "lazystartproducer":
+ case "lazyStartProducer": return target.isLazyStartProducer();
+ case "operation": return target.getOperation();
+ case "ttl": return target.getTtl();
+ default: return null;
+ }
+ }
+}
+
diff --git a/components/camel-state-store/camel-state-store/src/generated/java/org/apache/camel/component/statestore/StateStoreEndpointUriFactory.java b/components/camel-state-store/camel-state-store/src/generated/java/org/apache/camel/component/statestore/StateStoreEndpointUriFactory.java
new file mode 100644
index 000000000000..523cdbc05a04
--- /dev/null
+++ b/components/camel-state-store/camel-state-store/src/generated/java/org/apache/camel/component/statestore/StateStoreEndpointUriFactory.java
@@ -0,0 +1,81 @@
+/* Generated by camel build tools - do NOT edit this file! */
+package org.apache.camel.component.statestore;
+
+import javax.annotation.processing.Generated;
+import java.net.URISyntaxException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.camel.spi.EndpointUriFactory;
+
+/**
+ * Generated by camel build tools - do NOT edit this file!
+ */
+@Generated("org.apache.camel.maven.packaging.GenerateEndpointUriFactoryMojo")
+public class StateStoreEndpointUriFactory extends org.apache.camel.support.component.EndpointUriFactorySupport implements EndpointUriFactory {
+
+ private static final String BASE = ":storeName";
+
+ private static final Set<String> PROPERTY_NAMES;
+ private static final Set<String> SECRET_PROPERTY_NAMES;
+ private static final Set<String> ENDPOINT_IDENTITY_PROPERTY_NAMES;
+ private static final Map<String, String> MULTI_VALUE_PREFIXES;
+ static {
+ Set<String> props = new HashSet<>(5);
+ props.add("backend");
+ props.add("lazyStartProducer");
+ props.add("operation");
+ props.add("storeName");
+ props.add("ttl");
+ PROPERTY_NAMES = Collections.unmodifiableSet(props);
+ SECRET_PROPERTY_NAMES = Collections.emptySet();
+ ENDPOINT_IDENTITY_PROPERTY_NAMES = Collections.emptySet();
+ MULTI_VALUE_PREFIXES = Collections.emptyMap();
+ }
+
+ @Override
+ public boolean isEnabled(String scheme) {
+ return "state-store".equals(scheme);
+ }
+
+ @Override
+ public String buildUri(String scheme, Map<String, Object> properties, boolean encode) throws URISyntaxException {
+ String syntax = scheme + BASE;
+ String uri = syntax;
+
+ Map<String, Object> copy = new HashMap<>(properties);
+
+ uri = buildPathParameter(syntax, uri, "storeName", null, true, copy);
+ uri = buildQueryParameters(uri, copy, encode);
+ return uri;
+ }
+
+ @Override
+ public Set<String> propertyNames() {
+ return PROPERTY_NAMES;
+ }
+
+ @Override
+ public Set<String> secretPropertyNames() {
+ return SECRET_PROPERTY_NAMES;
+ }
+
+ @Override
+ public Set<String> endpointIdentityPropertyNames() {
+ return ENDPOINT_IDENTITY_PROPERTY_NAMES;
+ }
+
+ @Override
+ public Map<String, String> multiValuePrefixes() {
+ return MULTI_VALUE_PREFIXES;
+ }
+
+ @Override
+ public boolean isLenientProperties() {
+ return false;
+ }
+}
+
diff --git a/components/camel-state-store/camel-state-store/src/generated/resources/META-INF/org/apache/camel/component/statestore/state-store.json b/components/camel-state-store/camel-state-store/src/generated/resources/META-INF/org/apache/camel/component/statestore/state-store.json
new file mode 100644
index 000000000000..d90c315d879c
--- /dev/null
+++ b/components/camel-state-store/camel-state-store/src/generated/resources/META-INF/org/apache/camel/component/statestore/state-store.json
@@ -0,0 +1,42 @@
+{
+ "component": {
+ "kind": "component",
+ "name": "state-store",
+ "title": "State Store",
+ "description": "Perform key-value operations against a pluggable state store backend.",
+ "deprecated": false,
+ "firstVersion": "4.23.0",
+ "label": "cache",
+ "javaType": "org.apache.camel.component.statestore.StateStoreComponent",
+ "supportLevel": "Preview",
+ "groupId": "org.apache.camel",
+ "artifactId": "camel-state-store",
+ "version": "4.23.0-SNAPSHOT",
+ "scheme": "state-store",
+ "extendsScheme": "",
+ "syntax": "state-store:storeName",
+ "async": false,
+ "api": false,
+ "consumerOnly": false,
+ "producerOnly": true,
+ "lenientProperties": false,
+ "browsable": false,
+ "remote": true
+ },
+ "componentProperties": {
+ "lazyStartProducer": { "index": 0, "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail [...]
+ "autowiredEnabled": { "index": 1, "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching t [...]
+ },
+ "headers": {
+ "CamelStateStoreOperation": { "index": 0, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "org.apache.camel.component.statestore.StateStoreOperations", "enum": [ "put", "putIfAbsent", "get", "delete", "contains", "keys", "size", "clear" ], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The operation to perform", "constantName": "org.apache.camel.component.statestore.StateSt [...]
+ "CamelStateStoreKey": { "index": 1, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The key to use for the operation", "constantName": "org.apache.camel.component.statestore.StateStoreConstants#KEY" },
+ "CamelStateStoreTtl": { "index": 2, "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Per-message TTL override in milliseconds. Takes precedence over the endpoint ttl option.", "constantName": "org.apache.camel.component.statestore.StateStoreConstants#TTL" }
+ },
+ "properties": {
+ "storeName": { "index": 0, "kind": "path", "displayName": "Store Name", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The name of the state store" },
+ "operation": { "index": 1, "kind": "parameter", "displayName": "Operation", "group": "producer", "label": "", "required": false, "type": "enum", "javaType": "org.apache.camel.component.statestore.StateStoreOperations", "enum": [ "put", "putIfAbsent", "get", "delete", "contains", "keys", "size", "clear" ], "deprecated": false, "autowired": false, "secret": false, "description": "The default operation to perform" },
+ "ttl": { "index": 2, "kind": "parameter", "displayName": "Ttl", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 0, "description": "Time-to-live in milliseconds for entries. 0 means no expiry." },
+ "lazyStartProducer": { "index": 3, "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer (advanced)", "label": "producer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a produc [...]
+ "backend": { "index": 4, "kind": "parameter", "displayName": "Backend", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.statestore.StateStoreBackend", "deprecated": false, "autowired": false, "secret": false, "description": "The backend to use. If not set, auto-discovers a single StateStoreBackend from the registry, or falls back to an in-memory store." }
+ }
+}
diff --git a/components/camel-state-store/camel-state-store/src/generated/resources/META-INF/services/org/apache/camel/component.properties b/components/camel-state-store/camel-state-store/src/generated/resources/META-INF/services/org/apache/camel/component.properties
new file mode 100644
index 000000000000..0bbe17eb2ca8
--- /dev/null
+++ b/components/camel-state-store/camel-state-store/src/generated/resources/META-INF/services/org/apache/camel/component.properties
@@ -0,0 +1,7 @@
+# Generated by camel build tools - do NOT edit this file!
+components=state-store
+groupId=org.apache.camel
+artifactId=camel-state-store
+version=4.23.0-SNAPSHOT
+projectName=Camel :: State Store
+projectDescription=Camel State Store component for pluggable key-value store operations
diff --git a/components/camel-state-store/camel-state-store/src/generated/resources/META-INF/services/org/apache/camel/component/state-store b/components/camel-state-store/camel-state-store/src/generated/resources/META-INF/services/org/apache/camel/component/state-store
new file mode 100644
index 000000000000..e70c435ac7a3
--- /dev/null
+++ b/components/camel-state-store/camel-state-store/src/generated/resources/META-INF/services/org/apache/camel/component/state-store
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.component.statestore.StateStoreComponent
diff --git a/components/camel-state-store/camel-state-store/src/generated/resources/META-INF/services/org/apache/camel/configurer/state-store-component b/components/camel-state-store/camel-state-store/src/generated/resources/META-INF/services/org/apache/camel/configurer/state-store-component
new file mode 100644
index 000000000000..72500e5989c8
--- /dev/null
+++ b/components/camel-state-store/camel-state-store/src/generated/resources/META-INF/services/org/apache/camel/configurer/state-store-component
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.component.statestore.StateStoreComponentConfigurer
diff --git a/components/camel-state-store/camel-state-store/src/generated/resources/META-INF/services/org/apache/camel/configurer/state-store-endpoint b/components/camel-state-store/camel-state-store/src/generated/resources/META-INF/services/org/apache/camel/configurer/state-store-endpoint
new file mode 100644
index 000000000000..c7634332bfe4
--- /dev/null
+++ b/components/camel-state-store/camel-state-store/src/generated/resources/META-INF/services/org/apache/camel/configurer/state-store-endpoint
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.component.statestore.StateStoreEndpointConfigurer
diff --git a/components/camel-state-store/camel-state-store/src/generated/resources/META-INF/services/org/apache/camel/urifactory/state-store-endpoint b/components/camel-state-store/camel-state-store/src/generated/resources/META-INF/services/org/apache/camel/urifactory/state-store-endpoint
new file mode 100644
index 000000000000..0a9d439bef31
--- /dev/null
+++ b/components/camel-state-store/camel-state-store/src/generated/resources/META-INF/services/org/apache/camel/urifactory/state-store-endpoint
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.component.statestore.StateStoreEndpointUriFactory
diff --git a/components/camel-state-store/camel-state-store/src/main/docs/state-store-component.adoc b/components/camel-state-store/camel-state-store/src/main/docs/state-store-component.adoc
new file mode 100644
index 000000000000..8d2537e9df3d
--- /dev/null
+++ b/components/camel-state-store/camel-state-store/src/main/docs/state-store-component.adoc
@@ -0,0 +1,431 @@
+= State Store Component
+:doctitle: State Store
+:shortname: state-store
+:artifactid: camel-state-store
+:description: Perform key-value operations against a pluggable state store backend.
+:since: 4.23
+:supportlevel: Preview
+:tabs-sync-option:
+:component-header: Only producer is supported
+
+*Since Camel {since}*
+
+*{component-header}*
+
+The State Store component provides a simple, unified key-value store API with pluggable backends.
+It is useful for caching, session state, and scenarios where you need a simple object store
+(similar to MuleSoft's Object Store).
+
+By default, an in-memory backend is used (based on `ConcurrentHashMap`), but you can plug in
+any custom backend by implementing the `StateStoreBackend` interface or using one of the
+provided backend modules:
+
+== When to use State Store vs individual components
+
+Camel also provides dedicated components for xref:infinispan-component.adoc[Infinispan],
+xref:spring-redis-component.adoc[Redis], and xref:caffeine-cache-component.adoc[Caffeine].
+Use the dedicated component when you need the full feature set of a specific technology
+(e.g., Infinispan queries, Redis pub/sub, Caffeine statistics).
+
+Use State Store when:
+
+* You need a *simple key-value API* and want to switch backends without changing route logic.
+* You are *migrating from MuleSoft* and want an Object Store equivalent.
+* You want *backend portability* — develop with in-memory, deploy with Redis or Infinispan.
+* Your use case is limited to *put, get, delete, contains, keys* operations.
+
+[width="100%",cols="1,2,1",options="header"]
+|===
+| Backend | Module | Description
+| In-Memory | `camel-state-store` | Default. Uses `ConcurrentHashMap` with lazy TTL expiry. No external dependencies.
+| Caffeine | `camel-state-store-caffeine` | High-performance local cache with proper eviction and per-entry TTL.
+| Redis | `camel-state-store-redis` | Distributed store via Redisson. Supports per-entry TTL natively.
+| Infinispan | `camel-state-store-infinispan` | Distributed cache via Hot Rod client. Supports per-entry TTL via lifespan.
+|===
+
+== URI Format
+
+----
+state-store:storeName[?options]
+----
+
+Where `storeName` is a logical name for the store. Endpoints with the same `storeName`
+share the same backend instance within the same `CamelContext`.
+
+// component-configure options: START
+include::partial$component-configure-options.adoc[]
+// component-configure options: END
+
+// component options: START
+include::partial$component-configure-options.adoc[]
+include::partial$component-endpoint-options.adoc[]
+include::partial$component-endpoint-headers.adoc[]
+// component options: END
+
+// endpoint options: START
+// endpoint options: END
+
+== Operations
+
+The operation to perform is set via the URI option `operation` or the header `CamelStateStoreOperation`.
+
+[width="100%",cols="1,2,2,2",options="header"]
+|===
+| Operation | Description | Body (input) | Result (body output)
+| `put` | Store a value | The value to store | The previous value (or null)
+| `putIfAbsent` | Store only if key absent | The value to store | The existing value (or null if stored)
+| `get` | Retrieve a value | ignored | The stored value (or null)
+| `delete` | Remove a value | ignored | The removed value (or null)
+| `contains` | Check if key exists | ignored | Boolean
+| `keys` | List all keys | ignored | Set<String>
+| `size` | Count entries | ignored | Integer
+| `clear` | Remove all entries | ignored | null
+|===
+
+The key is specified via the header `CamelStateStoreKey` (required for `put`, `putIfAbsent`, `get`, `delete`, `contains`).
+
+== TTL (Time-to-Live)
+
+You can set a TTL (in milliseconds) for entries in two ways:
+
+* *Endpoint option*: applies to all `put`/`putIfAbsent` operations on that endpoint.
++
+----
+state-store:myStore?operation=put&ttl=60000
+----
+
+* *Per-message header*: the header `CamelStateStoreTtl` (Long) overrides the endpoint TTL for that message.
++
+[source,java]
+----
+from("direct:store")
+ .setHeader("CamelStateStoreKey", constant("myKey"))
+ .setHeader("CamelStateStoreTtl", constant(30000L))
+ .to("state-store:myStore?operation=put");
+----
+
+A TTL of `0` (default) means no expiry.
+
+== Examples
+
+=== Java DSL
+
+[tabs]
+====
+Put and Get::
++
+[source,java]
+----
+from("direct:store")
+ .setHeader("CamelStateStoreKey", constant("myKey"))
+ .to("state-store:myStore?operation=put");
+
+from("direct:retrieve")
+ .setHeader("CamelStateStoreKey", constant("myKey"))
+ .to("state-store:myStore?operation=get");
+----
+
+Dynamic operation via header::
++
+[source,java]
+----
+from("direct:dynamic")
+ .setHeader("CamelStateStoreOperation", constant("put"))
+ .setHeader("CamelStateStoreKey", constant("myKey"))
+ .to("state-store:myStore");
+----
+
+Put if absent::
++
+[source,java]
+----
+from("direct:init")
+ .setHeader("CamelStateStoreKey", constant("counter"))
+ .to("state-store:myStore?operation=putIfAbsent");
+----
+====
+
+=== YAML DSL
+
+[source,yaml]
+----
+- route:
+ from:
+ uri: direct:store
+ steps:
+ - setHeader:
+ name: CamelStateStoreKey
+ constant: myKey
+ - to:
+ uri: state-store:myStore?operation=put
+----
+
+== Backends
+
+=== Backend auto-discovery
+
+If no `backend` option is specified on the endpoint, the component automatically looks up a
+`StateStoreBackend` bean from the Camel registry. If exactly one is found, it is used for all
+endpoints. If none is found, the default in-memory backend is used.
+
+This means you can configure a backend once (via Java or properties) and all `state-store`
+endpoints will use it without needing `backend=#beanName` on each endpoint URI.
+
+=== Configuring backends via properties
+
+Backends can be configured entirely via `application.properties` using Camel's `camel.beans.*`
+syntax, without writing any Java code. This is especially useful for YAML DSL or Camel JBang users.
+
+[tabs]
+====
+Caffeine::
++
+[source,properties]
+----
+# application.properties
+camel.beans.caffeineBackend = #class:org.apache.camel.component.statestore.caffeine.CaffeineStateStoreBackend
+camel.beans.caffeineBackend.maximumSize = 50000
+----
+
+Redis::
++
+[source,properties]
+----
+# application.properties
+camel.beans.redisBackend = #class:org.apache.camel.component.statestore.redis.RedisStateStoreBackend
+camel.beans.redisBackend.redisUrl = redis://myhost:6379
+camel.beans.redisBackend.mapName = my-app-state
+----
+
+Infinispan::
++
+[source,properties]
+----
+# application.properties
+camel.beans.infinispanBackend = #class:org.apache.camel.component.statestore.infinispan.InfinispanStateStoreBackend
+camel.beans.infinispanBackend.hosts = myhost:11222
+camel.beans.infinispanBackend.cacheName = my-cache
+----
+====
+
+With the backend configured via properties and auto-discovery, no `backend=#...` reference
+is needed in the route:
+
+[source,yaml]
+----
+- route:
+ from:
+ uri: direct:store
+ steps:
+ - setHeader:
+ name: CamelStateStoreKey
+ constant: myKey
+ - to:
+ uri: state-store:myStore?operation=put
+----
+
+=== In-Memory (default)
+
+The default backend stores entries in a `ConcurrentHashMap`. TTL expiry is lazy -- entries are
+checked and removed on access rather than by a background thread.
+
+No additional dependency is needed beyond `camel-state-store`.
+
+=== Caffeine
+
+Add the dependency:
+
+[source,xml]
+----
+<dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-state-store-caffeine</artifactId>
+</dependency>
+----
+
+[tabs]
+====
+Java::
++
+[source,java]
+----
+@BindToRegistry("caffeineBackend")
+public CaffeineStateStoreBackend caffeine() {
+ CaffeineStateStoreBackend backend = new CaffeineStateStoreBackend();
+ backend.setMaximumSize(50_000); // default is 10,000
+ return backend;
+}
+----
+
+Properties::
++
+[source,properties]
+----
+camel.beans.caffeineBackend = #class:org.apache.camel.component.statestore.caffeine.CaffeineStateStoreBackend
+camel.beans.caffeineBackend.maximumSize = 50000
+----
+====
+
+With auto-discovery, the backend is picked up automatically. You can also reference it explicitly:
+
+[source,java]
+----
+from("direct:store")
+ .to("state-store:myStore?operation=put&backend=#caffeineBackend");
+----
+
+Caffeine provides proper eviction policies and active TTL expiration using variable expiry.
+
+=== Redis
+
+Add the dependency:
+
+[source,xml]
+----
+<dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-state-store-redis</artifactId>
+</dependency>
+----
+
+[tabs]
+====
+Java::
++
+[source,java]
+----
+@BindToRegistry("redisBackend")
+public RedisStateStoreBackend redis() {
+ RedisStateStoreBackend backend = new RedisStateStoreBackend();
+ backend.setRedisUrl("redis://myhost:6379");
+ backend.setMapName("my-app-state"); // Redis map name
+ return backend;
+}
+----
+
+Properties::
++
+[source,properties]
+----
+camel.beans.redisBackend = #class:org.apache.camel.component.statestore.redis.RedisStateStoreBackend
+camel.beans.redisBackend.redisUrl = redis://myhost:6379
+camel.beans.redisBackend.mapName = my-app-state
+----
+====
+
+You can also inject a pre-configured `RedissonClient`:
+
+[source,java]
+----
+backend.setRedisson(existingRedissonClient);
+----
+
+Redis provides native per-entry TTL via `RMapCache`. Data is distributed and persisted according
+to your Redis configuration.
+
+=== Infinispan
+
+Add the dependency:
+
+[source,xml]
+----
+<dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-state-store-infinispan</artifactId>
+</dependency>
+----
+
+[tabs]
+====
+Java::
++
+[source,java]
+----
+@BindToRegistry("infinispanBackend")
+public InfinispanStateStoreBackend infinispan() {
+ InfinispanStateStoreBackend backend = new InfinispanStateStoreBackend();
+ backend.setHosts("myhost:11222");
+ backend.setCacheName("my-cache");
+ return backend;
+}
+----
+
+Properties::
++
+[source,properties]
+----
+camel.beans.infinispanBackend = #class:org.apache.camel.component.statestore.infinispan.InfinispanStateStoreBackend
+camel.beans.infinispanBackend.hosts = myhost:11222
+camel.beans.infinispanBackend.cacheName = my-cache
+----
+====
+
+You can also inject a pre-configured `RemoteCacheManager`:
+
+[source,java]
+----
+backend.setCacheManager(existingCacheManager);
+----
+
+Infinispan provides native per-entry TTL via the lifespan parameter and supports distributed caching.
+
+== Custom Backend
+
+Implement the `StateStoreBackend` interface to create your own backend:
+
+[source,java]
+----
+public class MyCustomBackend implements StateStoreBackend {
+
+ @Override
+ public Object put(String key, Object value, long ttlMillis) {
+ // store the value, return previous
+ }
+
+ @Override
+ public Object get(String key) {
+ // retrieve the value
+ }
+
+ @Override
+ public Object delete(String key) {
+ // remove and return the value
+ }
+
+ @Override
+ public boolean contains(String key) {
+ // check existence
+ }
+
+ @Override
+ public Set<String> keys() {
+ // return all keys
+ }
+
+ @Override
+ public void clear() {
+ // remove all entries
+ }
+
+ @Override
+ public void start() {
+ // initialize connections
+ }
+
+ @Override
+ public void stop() {
+ // clean up resources
+ }
+}
+----
+
+The `putIfAbsent` and `size` methods have default implementations but can be overridden
+for better performance with backends that support these operations natively.
+
+Then reference it via bean or let auto-discovery find it:
+
+[source,java]
+----
+from("direct:store")
+ .to("state-store:myStore?operation=put&backend=#myCustomBackend");
+----
diff --git a/components/camel-state-store/camel-state-store/src/main/java/org/apache/camel/component/statestore/InMemoryStateStoreBackend.java b/components/camel-state-store/camel-state-store/src/main/java/org/apache/camel/component/statestore/InMemoryStateStoreBackend.java
new file mode 100644
index 000000000000..e98511c903a5
--- /dev/null
+++ b/components/camel-state-store/camel-state-store/src/main/java/org/apache/camel/component/statestore/InMemoryStateStoreBackend.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.statestore;
+
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Default in-memory implementation of {@link StateStoreBackend} using a {@link ConcurrentHashMap}. Supports optional
+ * TTL with lazy expiry (entries are checked on access, no background thread).
+ *
+ * @since 4.23
+ */
+public class InMemoryStateStoreBackend implements StateStoreBackend {
+
+ private final ConcurrentHashMap<String, Entry> store = new ConcurrentHashMap<>();
+
+ @Override
+ public Object put(String key, Object value, long ttlMillis) {
+ long expiresAt = ttlMillis > 0 ? System.currentTimeMillis() + ttlMillis : 0;
+ Entry previous = store.put(key, new Entry(value, expiresAt));
+ if (previous != null && !previous.isExpired()) {
+ return previous.value();
+ }
+ return null;
+ }
+
+ @Override
+ public Object get(String key) {
+ Entry entry = store.get(key);
+ if (entry == null) {
+ return null;
+ }
+ if (entry.isExpired()) {
+ store.remove(key, entry);
+ return null;
+ }
+ return entry.value();
+ }
+
+ @Override
+ public Object delete(String key) {
+ Entry entry = store.remove(key);
+ if (entry != null && !entry.isExpired()) {
+ return entry.value();
+ }
+ return null;
+ }
+
+ @Override
+ public boolean contains(String key) {
+ Entry entry = store.get(key);
+ if (entry == null) {
+ return false;
+ }
+ if (entry.isExpired()) {
+ store.remove(key, entry);
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public Object putIfAbsent(String key, Object value, long ttlMillis) {
+ long expiresAt = ttlMillis > 0 ? System.currentTimeMillis() + ttlMillis : 0;
+ Object[] result = new Object[1];
+ store.compute(key, (k, current) -> {
+ if (current == null || current.isExpired()) {
+ return new Entry(value, expiresAt);
+ }
+ result[0] = current.value();
+ return current;
+ });
+ return result[0];
+ }
+
+ @Override
+ public int size() {
+ evictExpired();
+ return store.size();
+ }
+
+ @Override
+ public Set<String> keys() {
+ evictExpired();
+ return Set.copyOf(store.keySet());
+ }
+
+ private void evictExpired() {
+ store.entrySet().removeIf(e -> e.getValue().isExpired());
+ }
+
+ @Override
+ public void clear() {
+ store.clear();
+ }
+
+ @Override
+ public void start() {
+ // no-op
+ }
+
+ @Override
+ public void stop() {
+ store.clear();
+ }
+
+ private record Entry(Object value, long expiresAt) {
+
+ boolean isExpired() {
+ return expiresAt > 0 && System.currentTimeMillis() > expiresAt;
+ }
+ }
+}
diff --git a/components/camel-state-store/camel-state-store/src/main/java/org/apache/camel/component/statestore/StateStoreBackend.java b/components/camel-state-store/camel-state-store/src/main/java/org/apache/camel/component/statestore/StateStoreBackend.java
new file mode 100644
index 000000000000..974f95e4f889
--- /dev/null
+++ b/components/camel-state-store/camel-state-store/src/main/java/org/apache/camel/component/statestore/StateStoreBackend.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.statestore;
+
+import java.util.Set;
+
+import org.apache.camel.Service;
+
+/**
+ * Interface for pluggable state store backends.
+ *
+ * @since 4.23
+ */
+public interface StateStoreBackend extends Service {
+
+ /**
+ * Store a value with the given key and optional TTL.
+ *
+ * @param key the key
+ * @param value the value to store
+ * @param ttlMillis time-to-live in milliseconds (0 = no expiry)
+ * @return the previous value associated with the key, or null
+ */
+ Object put(String key, Object value, long ttlMillis);
+
+ /**
+ * Store a value only if the key does not already exist.
+ * <p>
+ * <b>Note:</b> The default implementation is not atomic. Implementations that require thread safety should override
+ * this method with an atomic version (e.g., using the backing store's native putIfAbsent).
+ *
+ * @param key the key
+ * @param value the value to store
+ * @param ttlMillis time-to-live in milliseconds (0 = no expiry)
+ * @return the existing value if the key already exists, or null if the value was stored
+ */
+ default Object putIfAbsent(String key, Object value, long ttlMillis) {
+ if (contains(key)) {
+ return get(key);
+ }
+ put(key, value, ttlMillis);
+ return null;
+ }
+
+ /**
+ * Retrieve the value associated with the given key.
+ *
+ * @param key the key
+ * @return the value, or null if not found or expired
+ */
+ Object get(String key);
+
+ /**
+ * Remove the value associated with the given key.
+ *
+ * @param key the key
+ * @return the removed value, or null if not found
+ */
+ Object delete(String key);
+
+ /**
+ * Check if a key exists in the store.
+ *
+ * @param key the key
+ * @return true if the key exists and has not expired
+ */
+ boolean contains(String key);
+
+ /**
+ * Return all keys in the store.
+ *
+ * @return a set of all keys
+ */
+ Set<String> keys();
+
+ /**
+ * Return the number of entries in the store.
+ *
+ * @return the number of entries
+ */
+ default int size() {
+ return keys().size();
+ }
+
+ /**
+ * Remove all entries from the store.
+ */
+ void clear();
+}
diff --git a/components/camel-state-store/camel-state-store/src/main/java/org/apache/camel/component/statestore/StateStoreComponent.java b/components/camel-state-store/camel-state-store/src/main/java/org/apache/camel/component/statestore/StateStoreComponent.java
new file mode 100644
index 000000000000..33bdb526a837
--- /dev/null
+++ b/components/camel-state-store/camel-state-store/src/main/java/org/apache/camel/component/statestore/StateStoreComponent.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.statestore;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.spi.annotations.Component;
+import org.apache.camel.support.DefaultComponent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The State Store component provides a simple, unified key-value store API with pluggable backends.
+ *
+ * @since 4.23
+ */
+@Component("state-store")
+public class StateStoreComponent extends DefaultComponent {
+
+ private static final Logger LOG = LoggerFactory.getLogger(StateStoreComponent.class);
+
+ private final ConcurrentHashMap<String, StateStoreBackend> backends = new ConcurrentHashMap<>();
+
+ @Override
+ protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+ StateStoreEndpoint endpoint = new StateStoreEndpoint(uri, this);
+ endpoint.setStoreName(remaining);
+ setProperties(endpoint, parameters);
+ return endpoint;
+ }
+
+ /**
+ * Returns the backend for the given store name, creating one if needed. Uses first-one-wins semantics: if a backend
+ * already exists for this store name, subsequent calls return the existing one regardless of the explicit backend
+ * passed.
+ */
+ StateStoreBackend getOrCreateBackend(String storeName, StateStoreBackend explicitBackend) {
+ if (explicitBackend != null) {
+ StateStoreBackend existing = backends.putIfAbsent(storeName, explicitBackend);
+ if (existing != null) {
+ if (existing != explicitBackend) {
+ LOG.warn("Store '{}' already has a backend ({}). Ignoring explicit backend=# reference ({}).",
+ storeName, existing.getClass().getSimpleName(), explicitBackend.getClass().getSimpleName());
+ }
+ return existing;
+ }
+ explicitBackend.start();
+ return explicitBackend;
+ }
+ return backends.computeIfAbsent(storeName, k -> {
+ // Auto-discover a StateStoreBackend from the registry
+ Set<StateStoreBackend> found = getCamelContext().getRegistry().findByType(StateStoreBackend.class);
+ StateStoreBackend backend;
+ if (found.size() == 1) {
+ backend = found.iterator().next();
+ LOG.debug("Auto-discovered StateStoreBackend '{}' for store '{}'",
+ backend.getClass().getSimpleName(), storeName);
+ } else {
+ if (found.size() > 1) {
+ LOG.warn(
+ "Found {} StateStoreBackend instances in the registry for store '{}'. "
+ + "Cannot auto-select — falling back to InMemoryStateStoreBackend. "
+ + "Use an explicit backend=# reference to choose one.",
+ found.size(), storeName);
+ } else {
+ LOG.info("No StateStoreBackend found in the registry for store '{}'. Using InMemoryStateStoreBackend.",
+ storeName);
+ }
+ backend = new InMemoryStateStoreBackend();
+ }
+ backend.start();
+ return backend;
+ });
+ }
+
+ @Override
+ protected void doStop() throws Exception {
+ Exception firstException = null;
+ for (StateStoreBackend backend : backends.values()) {
+ try {
+ backend.stop();
+ } catch (Exception e) {
+ LOG.warn("Error stopping backend: {}", e.getMessage(), e);
+ if (firstException == null) {
+ firstException = e;
+ }
+ }
+ }
+ backends.clear();
+ super.doStop();
+ if (firstException != null) {
+ throw firstException;
+ }
+ }
+}
diff --git a/components/camel-state-store/camel-state-store/src/main/java/org/apache/camel/component/statestore/StateStoreConstants.java b/components/camel-state-store/camel-state-store/src/main/java/org/apache/camel/component/statestore/StateStoreConstants.java
new file mode 100644
index 000000000000..8b3ddb8d31a8
--- /dev/null
+++ b/components/camel-state-store/camel-state-store/src/main/java/org/apache/camel/component/statestore/StateStoreConstants.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.statestore;
+
+import org.apache.camel.spi.Metadata;
+
+/**
+ * Constants for the State Store component.
+ *
+ * @since 4.23
+ */
+public final class StateStoreConstants {
+
+ @Metadata(description = "The operation to perform", javaType = "org.apache.camel.component.statestore.StateStoreOperations",
+ label = "producer")
+ public static final String OPERATION = "CamelStateStoreOperation";
+
+ @Metadata(description = "The key to use for the operation", javaType = "String", label = "producer")
+ public static final String KEY = "CamelStateStoreKey";
+
+ @Metadata(description = "Per-message TTL override in milliseconds. Takes precedence over the endpoint ttl option.",
+ javaType = "Long", label = "producer")
+ public static final String TTL = "CamelStateStoreTtl";
+
+ private StateStoreConstants() {
+ }
+}
diff --git a/components/camel-state-store/camel-state-store/src/main/java/org/apache/camel/component/statestore/StateStoreEndpoint.java b/components/camel-state-store/camel-state-store/src/main/java/org/apache/camel/component/statestore/StateStoreEndpoint.java
new file mode 100644
index 000000000000..9b4fc426ec43
--- /dev/null
+++ b/components/camel-state-store/camel-state-store/src/main/java/org/apache/camel/component/statestore/StateStoreEndpoint.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.statestore;
+
+import org.apache.camel.Category;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
+import org.apache.camel.support.DefaultEndpoint;
+
+/**
+ * Perform key-value operations against a pluggable state store backend.
+ *
+ * @since 4.23
+ */
+@UriEndpoint(firstVersion = "4.23.0", scheme = "state-store", title = "State Store",
+ syntax = "state-store:storeName", producerOnly = true,
+ category = { Category.CACHE },
+ headersClass = StateStoreConstants.class)
+public class StateStoreEndpoint extends DefaultEndpoint {
+
+ @UriPath(description = "The name of the state store")
+ @Metadata(required = true)
+ private String storeName;
+
+ @UriParam(description = "The default operation to perform", enums = "put,putIfAbsent,get,delete,contains,keys,size,clear")
+ private StateStoreOperations operation;
+
+ @UriParam(description = "The backend to use. If not set, auto-discovers a single StateStoreBackend from the registry, or falls back to an in-memory store.",
+ label = "advanced")
+ private StateStoreBackend backend;
+
+ @UriParam(description = "Time-to-live in milliseconds for entries. 0 means no expiry.", defaultValue = "0")
+ private long ttl;
+
+ public StateStoreEndpoint(String endpointUri, StateStoreComponent component) {
+ super(endpointUri, component);
+ }
+
+ @Override
+ public Producer createProducer() {
+ return new StateStoreProducer(this);
+ }
+
+ @Override
+ public Consumer createConsumer(Processor processor) {
+ throw new UnsupportedOperationException("The state-store component does not support consumers");
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ super.doStart();
+ StateStoreComponent comp = (StateStoreComponent) getComponent();
+ backend = comp.getOrCreateBackend(storeName, backend);
+ }
+
+ public String getStoreName() {
+ return storeName;
+ }
+
+ public void setStoreName(String storeName) {
+ this.storeName = storeName;
+ }
+
+ public StateStoreOperations getOperation() {
+ return operation;
+ }
+
+ public void setOperation(StateStoreOperations operation) {
+ this.operation = operation;
+ }
+
+ public StateStoreBackend getBackend() {
+ return backend;
+ }
+
+ public void setBackend(StateStoreBackend backend) {
+ this.backend = backend;
+ }
+
+ public long getTtl() {
+ return ttl;
+ }
+
+ public void setTtl(long ttl) {
+ this.ttl = ttl;
+ }
+}
diff --git a/components/camel-state-store/camel-state-store/src/main/java/org/apache/camel/component/statestore/StateStoreOperations.java b/components/camel-state-store/camel-state-store/src/main/java/org/apache/camel/component/statestore/StateStoreOperations.java
new file mode 100644
index 000000000000..68ea3a5a0331
--- /dev/null
+++ b/components/camel-state-store/camel-state-store/src/main/java/org/apache/camel/component/statestore/StateStoreOperations.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.statestore;
+
+/**
+ * Operations supported by the State Store component.
+ *
+ * @since 4.23
+ */
+public enum StateStoreOperations {
+
+ put,
+ putIfAbsent,
+ get,
+ delete,
+ contains,
+ keys,
+ size,
+ clear;
+
+}
diff --git a/components/camel-state-store/camel-state-store/src/main/java/org/apache/camel/component/statestore/StateStoreProducer.java b/components/camel-state-store/camel-state-store/src/main/java/org/apache/camel/component/statestore/StateStoreProducer.java
new file mode 100644
index 000000000000..4c8a23128595
--- /dev/null
+++ b/components/camel-state-store/camel-state-store/src/main/java/org/apache/camel/component/statestore/StateStoreProducer.java
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.statestore;
+
+import java.util.Arrays;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.support.DefaultProducer;
+
+/**
+ * Producer for the State Store component that performs key-value operations.
+ *
+ * @since 4.23
+ */
+public class StateStoreProducer extends DefaultProducer {
+
+ private final StateStoreEndpoint endpoint;
+
+ public StateStoreProducer(StateStoreEndpoint endpoint) {
+ super(endpoint);
+ this.endpoint = endpoint;
+ }
+
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ StateStoreOperations op = determineOperation(exchange);
+ if (op == null) {
+ throw new IllegalArgumentException(
+ "No operation specified. Set the operation via URI option or header " + StateStoreConstants.OPERATION);
+ }
+
+ StateStoreBackend backend = endpoint.getBackend();
+ long ttl = determineTtl(exchange);
+ Message message = exchange.getMessage();
+
+ switch (op) {
+ case put -> {
+ String key = requireKey(message);
+ Object value = message.getBody();
+ Object previous = backend.put(key, value, ttl);
+ message.setBody(previous);
+ }
+ case putIfAbsent -> {
+ String key = requireKey(message);
+ Object value = message.getBody();
+ Object existing = backend.putIfAbsent(key, value, ttl);
+ message.setBody(existing);
+ }
+ case get -> {
+ String key = requireKey(message);
+ Object value = backend.get(key);
+ message.setBody(value);
+ }
+ case delete -> {
+ String key = requireKey(message);
+ Object removed = backend.delete(key);
+ message.setBody(removed);
+ }
+ case contains -> {
+ String key = requireKey(message);
+ boolean exists = backend.contains(key);
+ message.setBody(exists);
+ }
+ case keys -> {
+ message.setBody(backend.keys());
+ }
+ case size -> {
+ message.setBody(backend.size());
+ }
+ case clear -> {
+ backend.clear();
+ message.setBody(null);
+ }
+ default -> throw new IllegalArgumentException("Unsupported operation: " + op);
+ }
+ }
+
+ private StateStoreOperations determineOperation(Exchange exchange) {
+ Object headerOp = exchange.getMessage().getHeader(StateStoreConstants.OPERATION);
+ if (headerOp != null) {
+ if (headerOp instanceof StateStoreOperations sso) {
+ return sso;
+ }
+ String opName = headerOp.toString().trim();
+ try {
+ return StateStoreOperations.valueOf(opName);
+ } catch (IllegalArgumentException e) {
+ // Try case-insensitive lookup
+ for (StateStoreOperations candidate : StateStoreOperations.values()) {
+ if (candidate.name().equalsIgnoreCase(opName)) {
+ return candidate;
+ }
+ }
+ throw new IllegalArgumentException(
+ "Invalid operation '" + opName + "'. Valid operations: "
+ + Arrays.toString(StateStoreOperations.values()));
+ }
+ }
+ return endpoint.getOperation();
+ }
+
+ private long determineTtl(Exchange exchange) {
+ Long headerTtl = exchange.getMessage().getHeader(StateStoreConstants.TTL, Long.class);
+ if (headerTtl != null) {
+ return headerTtl;
+ }
+ return endpoint.getTtl();
+ }
+
+ private String requireKey(Message message) {
+ String key = message.getHeader(StateStoreConstants.KEY, String.class);
+ if (key == null) {
+ throw new IllegalArgumentException("Header " + StateStoreConstants.KEY + " is required for this operation");
+ }
+ return key;
+ }
+}
diff --git a/components/camel-state-store/camel-state-store/src/test/java/org/apache/camel/component/statestore/StateStoreAutoDiscoveryTest.java b/components/camel-state-store/camel-state-store/src/test/java/org/apache/camel/component/statestore/StateStoreAutoDiscoveryTest.java
new file mode 100644
index 000000000000..f16c429d950c
--- /dev/null
+++ b/components/camel-state-store/camel-state-store/src/test/java/org/apache/camel/component/statestore/StateStoreAutoDiscoveryTest.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.statestore;
+
+import java.util.Map;
+
+import org.apache.camel.BindToRegistry;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Tests that a single {@link StateStoreBackend} in the registry is auto-discovered when no explicit backend is
+ * specified on the endpoint.
+ */
+class StateStoreAutoDiscoveryTest extends CamelTestSupport {
+
+ private final TrackingInMemoryBackend trackingBackend = new TrackingInMemoryBackend();
+
+ @BindToRegistry("myBackend")
+ public StateStoreBackend getBackend() {
+ return trackingBackend;
+ }
+
+ @Test
+ void testAutoDiscoveryFromRegistry() {
+ // No backend=#myBackend in the URI, should auto-discover from registry
+ template.requestBodyAndHeaders(
+ "direct:put", "hello",
+ Map.of(StateStoreConstants.KEY, "key1"));
+
+ Object result = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(result).isEqualTo("hello");
+
+ // Verify our tracking backend was used, not the default InMemoryStateStoreBackend
+ assertThat(trackingBackend).isInstanceOf(TrackingInMemoryBackend.class);
+ assertThat(trackingBackend.keys()).containsExactly("key1");
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ // No backend=# reference — relies on auto-discovery
+ from("direct:put").to("state-store:myStore?operation=put");
+ from("direct:get").to("state-store:myStore?operation=get");
+ }
+ };
+ }
+
+ /**
+ * A simple wrapper around InMemoryStateStoreBackend to verify it was used instead of a fresh default instance.
+ */
+ static class TrackingInMemoryBackend extends InMemoryStateStoreBackend {
+ }
+}
diff --git a/components/camel-state-store/camel-state-store/src/test/java/org/apache/camel/component/statestore/StateStoreMultiBackendFallbackTest.java b/components/camel-state-store/camel-state-store/src/test/java/org/apache/camel/component/statestore/StateStoreMultiBackendFallbackTest.java
new file mode 100644
index 000000000000..1795462e00dc
--- /dev/null
+++ b/components/camel-state-store/camel-state-store/src/test/java/org/apache/camel/component/statestore/StateStoreMultiBackendFallbackTest.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.statestore;
+
+import java.util.Map;
+
+import org.apache.camel.BindToRegistry;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Tests that when multiple {@link StateStoreBackend} instances are in the registry and no explicit backend is
+ * specified, the component falls back to {@link InMemoryStateStoreBackend} and logs a warning.
+ */
+class StateStoreMultiBackendFallbackTest extends CamelTestSupport {
+
+ @BindToRegistry("backend1")
+ private final InMemoryStateStoreBackend backendOne = new InMemoryStateStoreBackend();
+
+ @BindToRegistry("backend2")
+ private final InMemoryStateStoreBackend backendTwo = new InMemoryStateStoreBackend();
+
+ @Test
+ void testFallsBackToInMemoryWhenMultipleBackends() {
+ // With two backends in the registry and no explicit reference,
+ // auto-discovery should fall back to a fresh InMemoryStateStoreBackend
+ Object previous = template.requestBodyAndHeaders(
+ "direct:put", "hello",
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(previous).isNull();
+
+ Object result = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(result).isEqualTo("hello");
+
+ // Verify neither registered backend was used
+ assertThat(backendOne.size()).isZero();
+ assertThat(backendTwo.size()).isZero();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:put").to("state-store:myStore?operation=put");
+ from("direct:get").to("state-store:myStore?operation=get");
+ }
+ };
+ }
+}
diff --git a/components/camel-state-store/camel-state-store/src/test/java/org/apache/camel/component/statestore/StateStoreTest.java b/components/camel-state-store/camel-state-store/src/test/java/org/apache/camel/component/statestore/StateStoreTest.java
new file mode 100644
index 000000000000..5b32668e0095
--- /dev/null
+++ b/components/camel-state-store/camel-state-store/src/test/java/org/apache/camel/component/statestore/StateStoreTest.java
@@ -0,0 +1,269 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.statestore;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.awaitility.Awaitility.await;
+
+class StateStoreTest extends CamelTestSupport {
+
+ @Test
+ void testPutAndGet() {
+ Object previous = template.requestBodyAndHeaders(
+ "direct:put", "hello",
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(previous).isNull();
+
+ Object result = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(result).isEqualTo("hello");
+ }
+
+ @Test
+ void testPutReturnsOldValue() {
+ template.requestBodyAndHeaders(
+ "direct:put", "first",
+ Map.of(StateStoreConstants.KEY, "key1"));
+
+ Object previous = template.requestBodyAndHeaders(
+ "direct:put", "second",
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(previous).isEqualTo("first");
+ }
+
+ @Test
+ void testGetNonExistent() {
+ Object result = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "missing"));
+ assertThat(result).isNull();
+ }
+
+ @Test
+ void testDelete() {
+ template.requestBodyAndHeaders(
+ "direct:put", "value",
+ Map.of(StateStoreConstants.KEY, "key1"));
+
+ Object removed = template.requestBodyAndHeaders(
+ "direct:delete", null,
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(removed).isEqualTo("value");
+
+ Object result = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(result).isNull();
+ }
+
+ @Test
+ void testContains() {
+ template.requestBodyAndHeaders(
+ "direct:put", "value",
+ Map.of(StateStoreConstants.KEY, "key1"));
+
+ Object exists = template.requestBodyAndHeaders(
+ "direct:contains", null,
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(exists).isEqualTo(true);
+
+ Object notExists = template.requestBodyAndHeaders(
+ "direct:contains", null,
+ Map.of(StateStoreConstants.KEY, "missing"));
+ assertThat(notExists).isEqualTo(false);
+ }
+
+ @Test
+ @SuppressWarnings("unchecked")
+ void testKeys() {
+ template.requestBodyAndHeaders(
+ "direct:put", "v1",
+ Map.of(StateStoreConstants.KEY, "a"));
+ template.requestBodyAndHeaders(
+ "direct:put", "v2",
+ Map.of(StateStoreConstants.KEY, "b"));
+
+ Set<String> keys = (Set<String>) template.requestBody("direct:keys", (Object) null);
+ assertThat(keys).containsExactlyInAnyOrder("a", "b");
+ }
+
+ @Test
+ void testSize() {
+ template.requestBodyAndHeaders(
+ "direct:put", "v1",
+ Map.of(StateStoreConstants.KEY, "a"));
+ template.requestBodyAndHeaders(
+ "direct:put", "v2",
+ Map.of(StateStoreConstants.KEY, "b"));
+
+ Object size = template.requestBody("direct:size", (Object) null);
+ assertThat(size).isEqualTo(2);
+ }
+
+ @Test
+ void testClear() {
+ template.requestBodyAndHeaders(
+ "direct:put", "v1",
+ Map.of(StateStoreConstants.KEY, "a"));
+
+ template.requestBody("direct:clear", (Object) null);
+
+ Object result = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "a"));
+ assertThat(result).isNull();
+ }
+
+ @Test
+ void testPutIfAbsent() {
+ // first put should succeed
+ Object result = template.requestBodyAndHeaders(
+ "direct:putIfAbsent", "first",
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(result).isNull();
+
+ // second put should return existing value
+ result = template.requestBodyAndHeaders(
+ "direct:putIfAbsent", "second",
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(result).isEqualTo("first");
+
+ // verify original value is still there
+ Object value = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "key1"));
+ assertThat(value).isEqualTo("first");
+ }
+
+ @Test
+ void testOperationViaHeader() {
+ template.requestBodyAndHeaders(
+ "direct:dynamic", "hello",
+ Map.of(
+ StateStoreConstants.OPERATION, StateStoreOperations.put,
+ StateStoreConstants.KEY, "key1"));
+
+ Object result = template.requestBodyAndHeaders(
+ "direct:dynamic", null,
+ Map.of(
+ StateStoreConstants.OPERATION, "get",
+ StateStoreConstants.KEY, "key1"));
+ assertThat(result).isEqualTo("hello");
+ }
+
+ @Test
+ void testPerMessageTtlHeader() {
+ // put with per-message TTL of 200ms (no TTL on endpoint)
+ template.requestBodyAndHeaders(
+ "direct:put", "expiring",
+ Map.of(
+ StateStoreConstants.KEY, "ttlKey",
+ StateStoreConstants.TTL, 200L));
+
+ // should be there immediately
+ Object result = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "ttlKey"));
+ assertThat(result).isEqualTo("expiring");
+
+ // wait for TTL to expire
+ await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+ Object expired = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "ttlKey"));
+ assertThat(expired).isNull();
+ });
+ }
+
+ @Test
+ void testMissingKeyHeaderThrows() {
+ assertThatThrownBy(() -> template.requestBody("direct:get", (Object) null))
+ .isInstanceOf(CamelExecutionException.class)
+ .hasCauseInstanceOf(IllegalArgumentException.class);
+ }
+
+ @Test
+ void testDeleteNonExistentKey() {
+ Object removed = template.requestBodyAndHeaders(
+ "direct:delete", null,
+ Map.of(StateStoreConstants.KEY, "no-such-key"));
+ assertThat(removed).isNull();
+ }
+
+ @Test
+ void testInvalidOperationThrows() {
+ assertThatThrownBy(() -> template.requestBodyAndHeaders(
+ "direct:dynamic", "value",
+ Map.of(StateStoreConstants.OPERATION, "INVALID_OP",
+ StateStoreConstants.KEY, "key1")))
+ .isInstanceOf(CamelExecutionException.class)
+ .hasCauseInstanceOf(IllegalArgumentException.class);
+ }
+
+ @Test
+ void testCaseInsensitiveOperation() {
+ // "PUT" in uppercase should work (case-insensitive fallback)
+ template.requestBodyAndHeaders(
+ "direct:dynamic", "hello",
+ Map.of(
+ StateStoreConstants.OPERATION, "PUT",
+ StateStoreConstants.KEY, "key1"));
+
+ Object result = template.requestBodyAndHeaders(
+ "direct:dynamic", null,
+ Map.of(
+ StateStoreConstants.OPERATION, "Get",
+ StateStoreConstants.KEY, "key1"));
+ assertThat(result).isEqualTo("hello");
+ }
+
+ @Test
+ void testMissingOperationThrows() {
+ assertThatThrownBy(() -> template.requestBodyAndHeaders("direct:dynamic", "value", Map.of()))
+ .isInstanceOf(CamelExecutionException.class)
+ .hasCauseInstanceOf(IllegalArgumentException.class);
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:put").to("state-store:myStore?operation=put");
+ from("direct:putIfAbsent").to("state-store:myStore?operation=putIfAbsent");
+ from("direct:get").to("state-store:myStore?operation=get");
+ from("direct:delete").to("state-store:myStore?operation=delete");
+ from("direct:contains").to("state-store:myStore?operation=contains");
+ from("direct:keys").to("state-store:myStore?operation=keys");
+ from("direct:size").to("state-store:myStore?operation=size");
+ from("direct:clear").to("state-store:myStore?operation=clear");
+ from("direct:dynamic").to("state-store:myStore");
+ }
+ };
+ }
+}
diff --git a/components/camel-state-store/camel-state-store/src/test/java/org/apache/camel/component/statestore/StateStoreTtlTest.java b/components/camel-state-store/camel-state-store/src/test/java/org/apache/camel/component/statestore/StateStoreTtlTest.java
new file mode 100644
index 000000000000..4c3f1f1f6864
--- /dev/null
+++ b/components/camel-state-store/camel-state-store/src/test/java/org/apache/camel/component/statestore/StateStoreTtlTest.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.statestore;
+
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.awaitility.Awaitility.await;
+
+class StateStoreTtlTest extends CamelTestSupport {
+
+ @Test
+ void testEntryExpiresAfterTtl() {
+ // put a value with 200ms TTL
+ template.requestBodyAndHeaders(
+ "direct:put", "expiring",
+ Map.of(StateStoreConstants.KEY, "ttlKey"));
+
+ // should be retrievable immediately
+ Object result = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "ttlKey"));
+ assertThat(result).isEqualTo("expiring");
+
+ // wait for TTL to expire
+ await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+ Object expired = template.requestBodyAndHeaders(
+ "direct:get", null,
+ Map.of(StateStoreConstants.KEY, "ttlKey"));
+ assertThat(expired).isNull();
+ });
+ }
+
+ @Test
+ void testContainsReturnsFalseAfterTtl() {
+ template.requestBodyAndHeaders(
+ "direct:put", "expiring",
+ Map.of(StateStoreConstants.KEY, "ttlKey"));
+
+ await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+ Object exists = template.requestBodyAndHeaders(
+ "direct:contains", null,
+ Map.of(StateStoreConstants.KEY, "ttlKey"));
+ assertThat(exists).isEqualTo(false);
+ });
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:put").to("state-store:ttlStore?operation=put&ttl=200");
+ from("direct:get").to("state-store:ttlStore?operation=get");
+ from("direct:contains").to("state-store:ttlStore?operation=contains");
+ }
+ };
+ }
+}
diff --git a/components/camel-state-store/pom.xml b/components/camel-state-store/pom.xml
new file mode 100644
index 000000000000..2e28ec5e33c4
--- /dev/null
+++ b/components/camel-state-store/pom.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>components</artifactId>
+ <version>4.23.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-state-store-parent</artifactId>
+ <packaging>pom</packaging>
+
+ <name>Camel :: State Store :: Parent</name>
+ <description>Camel State Store parent</description>
+
+ <modules>
+ <module>camel-state-store</module>
+ <module>camel-state-store-caffeine</module>
+ <module>camel-state-store-redis</module>
+ <module>camel-state-store-infinispan</module>
+ </modules>
+
+</project>
diff --git a/components/pom.xml b/components/pom.xml
index c00bfb41f02d..e2b5e96c2993 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -313,6 +313,7 @@
<module>camel-splunk-hec</module>
<module>camel-sql</module>
<module>camel-ssh</module>
+ <module>camel-state-store</module>
<module>camel-stax</module>
<module>camel-stream</module>
<module>camel-stringtemplate</module>
diff --git a/core/camel-main/src/generated/resources/org/apache/camel/main/components.properties b/core/camel-main/src/generated/resources/org/apache/camel/main/components.properties
index 7daa5f5e70f6..6dc929e6fe02 100644
--- a/core/camel-main/src/generated/resources/org/apache/camel/main/components.properties
+++ b/core/camel-main/src/generated/resources/org/apache/camel/main/components.properties
@@ -362,6 +362,7 @@ spring-ws
sql
sql-stored
ssh
+state-store
stax
stitch
stream
diff --git a/docs/components/modules/ROOT/examples/json/state-store.json b/docs/components/modules/ROOT/examples/json/state-store.json
new file mode 120000
index 000000000000..41b189852813
--- /dev/null
+++ b/docs/components/modules/ROOT/examples/json/state-store.json
@@ -0,0 +1 @@
+../../../../../../components/camel-state-store/camel-state-store/src/generated/resources/META-INF/org/apache/camel/component/statestore/state-store.json
\ No newline at end of file
diff --git a/docs/components/modules/ROOT/nav.adoc b/docs/components/modules/ROOT/nav.adoc
index 8e7a6883ad5b..2bba8c55600e 100644
--- a/docs/components/modules/ROOT/nav.adoc
+++ b/docs/components/modules/ROOT/nav.adoc
@@ -374,6 +374,7 @@
** xref:sql-component.adoc[SQL]
** xref:sql-stored-component.adoc[SQL Stored Procedure]
** xref:ssh-component.adoc[SSH]
+** xref:state-store-component.adoc[State Store]
** xref:stax-component.adoc[StAX]
** xref:stitch-component.adoc[Stitch]
** xref:stream-component.adoc[Stream]
diff --git a/docs/components/modules/ROOT/pages/state-store-component.adoc b/docs/components/modules/ROOT/pages/state-store-component.adoc
new file mode 120000
index 000000000000..2ccd74acd050
--- /dev/null
+++ b/docs/components/modules/ROOT/pages/state-store-component.adoc
@@ -0,0 +1 @@
+../../../../../components/camel-state-store/camel-state-store/src/main/docs/state-store-component.adoc
\ No newline at end of file
diff --git a/docs/components/modules/others/examples/json/state-store-caffeine.json b/docs/components/modules/others/examples/json/state-store-caffeine.json
new file mode 120000
index 000000000000..15277f9fe668
--- /dev/null
+++ b/docs/components/modules/others/examples/json/state-store-caffeine.json
@@ -0,0 +1 @@
+../../../../../../components/camel-state-store/camel-state-store-caffeine/src/generated/resources/state-store-caffeine.json
\ No newline at end of file
diff --git a/docs/components/modules/others/examples/json/state-store-infinispan.json b/docs/components/modules/others/examples/json/state-store-infinispan.json
new file mode 120000
index 000000000000..9e22e40328f2
--- /dev/null
+++ b/docs/components/modules/others/examples/json/state-store-infinispan.json
@@ -0,0 +1 @@
+../../../../../../components/camel-state-store/camel-state-store-infinispan/src/generated/resources/state-store-infinispan.json
\ No newline at end of file
diff --git a/docs/components/modules/others/examples/json/state-store-redis.json b/docs/components/modules/others/examples/json/state-store-redis.json
new file mode 120000
index 000000000000..aac04d819206
--- /dev/null
+++ b/docs/components/modules/others/examples/json/state-store-redis.json
@@ -0,0 +1 @@
+../../../../../../components/camel-state-store/camel-state-store-redis/src/generated/resources/state-store-redis.json
\ No newline at end of file
diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/ComponentsBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/ComponentsBuilderFactory.java
index 5cc2a1f341e6..282d74fadb48 100644
--- a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/ComponentsBuilderFactory.java
+++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/ComponentsBuilderFactory.java
@@ -4885,6 +4885,19 @@ public interface ComponentsBuilderFactory {
static SshComponentBuilderFactory.SshComponentBuilder ssh() {
return SshComponentBuilderFactory.ssh();
}
+ /**
+ * State Store (camel-state-store)
+ * Perform key-value operations against a pluggable state store backend.
+ *
+ * Category: cache
+ * Since: 4.23
+ * Maven coordinates: org.apache.camel:camel-state-store
+ *
+ * @return the dsl builder
+ */
+ static StateStoreComponentBuilderFactory.StateStoreComponentBuilder stateStore() {
+ return StateStoreComponentBuilderFactory.stateStore();
+ }
/**
* StAX (camel-stax)
* Process XML payloads by a SAX ContentHandler.
diff --git a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/StateStoreComponentBuilderFactory.java b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/StateStoreComponentBuilderFactory.java
new file mode 100644
index 000000000000..c7f95c5694d0
--- /dev/null
+++ b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/StateStoreComponentBuilderFactory.java
@@ -0,0 +1,120 @@
+/* Generated by camel build tools - do NOT edit this file! */
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.builder.component.dsl;
+
+import javax.annotation.processing.Generated;
+import org.apache.camel.Component;
+import org.apache.camel.builder.component.AbstractComponentBuilder;
+import org.apache.camel.builder.component.ComponentBuilder;
+import org.apache.camel.component.statestore.StateStoreComponent;
+
+/**
+ * Perform key-value operations against a pluggable state store backend.
+ *
+ * Generated by camel build tools - do NOT edit this file!
+ */
+@Generated("org.apache.camel.maven.packaging.ComponentDslMojo")
+public interface StateStoreComponentBuilderFactory {
+
+ /**
+ * State Store (camel-state-store)
+ * Perform key-value operations against a pluggable state store backend.
+ *
+ * Category: cache
+ * Since: 4.23
+ * Maven coordinates: org.apache.camel:camel-state-store
+ *
+ * @return the dsl builder
+ */
+ static StateStoreComponentBuilder stateStore() {
+ return new StateStoreComponentBuilderImpl();
+ }
+
+ /**
+ * Builder for the State Store component.
+ */
+ interface StateStoreComponentBuilder extends ComponentBuilder<StateStoreComponent> {
+
+
+ /**
+ * Whether the producer should be started lazy (on the first message).
+ * By starting lazy you can use this to allow CamelContext and routes to
+ * startup in situations where a producer may otherwise fail during
+ * starting and cause the route to fail being started. By deferring this
+ * startup to be lazy then the startup failure can be handled during
+ * routing messages via Camel's routing error handlers. Beware that when
+ * the first message is processed then creating and starting the
+ * producer may take a little time and prolong the total processing time
+ * of the processing.
+ *
+ * The option is a: <code>boolean</code> type.
+ *
+ * Default: false
+ * Group: producer
+ *
+ * @param lazyStartProducer the value to set
+ * @return the dsl builder
+ */
+ default StateStoreComponentBuilder lazyStartProducer(boolean lazyStartProducer) {
+ doSetProperty("lazyStartProducer", lazyStartProducer);
+ return this;
+ }
+
+
+ /**
+ * Whether autowiring is enabled. This is used for automatic autowiring
+ * options (the option must be marked as autowired) by looking up in the
+ * registry to find if there is a single instance of matching type,
+ * which then gets configured on the component. This can be used for
+ * automatic configuring JDBC data sources, JMS connection factories,
+ * AWS Clients, etc.
+ *
+ * The option is a: <code>boolean</code> type.
+ *
+ * Default: true
+ * Group: advanced
+ *
+ * @param autowiredEnabled the value to set
+ * @return the dsl builder
+ */
+ default StateStoreComponentBuilder autowiredEnabled(boolean autowiredEnabled) {
+ doSetProperty("autowiredEnabled", autowiredEnabled);
+ return this;
+ }
+ }
+
+ class StateStoreComponentBuilderImpl
+ extends AbstractComponentBuilder<StateStoreComponent>
+ implements StateStoreComponentBuilder {
+ @Override
+ protected StateStoreComponent buildConcreteComponent() {
+ return new StateStoreComponent();
+ }
+ @Override
+ protected boolean setPropertyOnComponent(
+ Component component,
+ String name,
+ Object value) {
+ switch (name) {
+ case "lazyStartProducer": ((StateStoreComponent) component).setLazyStartProducer((boolean) value); return true;
+ case "autowiredEnabled": ((StateStoreComponent) component).setAutowiredEnabled((boolean) value); return true;
+ default: return false;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointBuilderFactory.java
index edc7c01f4c84..40c577751cf2 100644
--- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointBuilderFactory.java
+++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointBuilderFactory.java
@@ -370,6 +370,7 @@ public interface EndpointBuilderFactory
org.apache.camel.builder.endpoint.dsl.Sqs2EndpointBuilderFactory.Sqs2Builders,
org.apache.camel.builder.endpoint.dsl.SshEndpointBuilderFactory.SshBuilders,
org.apache.camel.builder.endpoint.dsl.StAXEndpointBuilderFactory.StAXBuilders,
+ org.apache.camel.builder.endpoint.dsl.StateStoreEndpointBuilderFactory.StateStoreBuilders,
org.apache.camel.builder.endpoint.dsl.StepFunctions2EndpointBuilderFactory.StepFunctions2Builders,
org.apache.camel.builder.endpoint.dsl.StitchEndpointBuilderFactory.StitchBuilders,
org.apache.camel.builder.endpoint.dsl.StreamEndpointBuilderFactory.StreamBuilders,
diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointBuilders.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointBuilders.java
index b3a69be4660e..3a5bc1bf5334 100644
--- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointBuilders.java
+++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointBuilders.java
@@ -367,6 +367,7 @@ public interface EndpointBuilders
org.apache.camel.builder.endpoint.dsl.Sqs2EndpointBuilderFactory,
org.apache.camel.builder.endpoint.dsl.SshEndpointBuilderFactory,
org.apache.camel.builder.endpoint.dsl.StAXEndpointBuilderFactory,
+ org.apache.camel.builder.endpoint.dsl.StateStoreEndpointBuilderFactory,
org.apache.camel.builder.endpoint.dsl.StepFunctions2EndpointBuilderFactory,
org.apache.camel.builder.endpoint.dsl.StitchEndpointBuilderFactory,
org.apache.camel.builder.endpoint.dsl.StreamEndpointBuilderFactory,
diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointHeaderBuilders.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointHeaderBuilders.java
index 1fef5db86215..254b707d7bd0 100644
--- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointHeaderBuilders.java
+++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/EndpointHeaderBuilders.java
@@ -3755,6 +3755,19 @@ public class EndpointHeaderBuilders {
public static SshEndpointBuilderFactory.SshHeaderNameBuilder ssh() {
return SshEndpointBuilderFactory.SshHeaderNameBuilder.INSTANCE;
}
+ /**
+ * State Store (camel-state-store)
+ * Perform key-value operations against a pluggable state store backend.
+ *
+ * Category: cache
+ * Since: 4.23
+ * Maven coordinates: org.apache.camel:camel-state-store
+ *
+ * @return the dsl builder for the headers' name.
+ */
+ public static StateStoreEndpointBuilderFactory.StateStoreHeaderNameBuilder stateStore() {
+ return StateStoreEndpointBuilderFactory.StateStoreHeaderNameBuilder.INSTANCE;
+ }
/**
* Stitch (camel-stitch)
* Stitch is a cloud ETL service that integrates various data sources into a
diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java
index 56a0c0f6a6ae..70e8315d221b 100644
--- a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java
+++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java
@@ -16353,6 +16353,46 @@ public class StaticEndpointBuilders {
public static SshEndpointBuilderFactory.SshEndpointBuilder ssh(String componentName, String path) {
return SshEndpointBuilderFactory.endpointBuilder(componentName, path);
}
+ /**
+ * State Store (camel-state-store)
+ * Perform key-value operations against a pluggable state store backend.
+ *
+ * Category: cache
+ * Since: 4.23
+ * Maven coordinates: org.apache.camel:camel-state-store
+ *
+ * Syntax: <code>state-store:storeName</code>
+ *
+ * Path parameter: storeName (required)
+ * The name of the state store
+ *
+ * @param path storeName
+ * @return the dsl builder
+ */
+ public static StateStoreEndpointBuilderFactory.StateStoreEndpointBuilder stateStore(String path) {
+ return stateStore("state-store", path);
+ }
+ /**
+ * State Store (camel-state-store)
+ * Perform key-value operations against a pluggable state store backend.
+ *
+ * Category: cache
+ * Since: 4.23
+ * Maven coordinates: org.apache.camel:camel-state-store
+ *
+ * Syntax: <code>state-store:storeName</code>
+ *
+ * Path parameter: storeName (required)
+ * The name of the state store
+ *
+ * @param componentName to use a custom component name for the endpoint
+ * instead of the default name
+ * @param path storeName
+ * @return the dsl builder
+ */
+ public static StateStoreEndpointBuilderFactory.StateStoreEndpointBuilder stateStore(String componentName, String path) {
+ return StateStoreEndpointBuilderFactory.endpointBuilder(componentName, path);
+ }
/**
* StAX (camel-stax)
* Process XML payloads by a SAX ContentHandler.
diff --git a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/StateStoreEndpointBuilderFactory.java b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/StateStoreEndpointBuilderFactory.java
new file mode 100644
index 000000000000..3e9d10aaf56a
--- /dev/null
+++ b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/StateStoreEndpointBuilderFactory.java
@@ -0,0 +1,316 @@
+/* Generated by camel build tools - do NOT edit this file! */
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.builder.endpoint.dsl;
+
+import java.util.*;
+import java.util.concurrent.*;
+import java.util.function.*;
+import java.util.stream.*;
+import javax.annotation.processing.Generated;
+import org.apache.camel.builder.EndpointConsumerBuilder;
+import org.apache.camel.builder.EndpointProducerBuilder;
+import org.apache.camel.builder.endpoint.AbstractEndpointBuilder;
+
+/**
+ * Perform key-value operations against a pluggable state store backend.
+ *
+ * Generated by camel build tools - do NOT edit this file!
+ */
+@Generated("org.apache.camel.maven.packaging.EndpointDslMojo")
+public interface StateStoreEndpointBuilderFactory {
+
+ /**
+ * Builder for endpoint for the State Store component.
+ */
+ public interface StateStoreEndpointBuilder
+ extends
+ EndpointProducerBuilder {
+ default AdvancedStateStoreEndpointBuilder advanced() {
+ return (AdvancedStateStoreEndpointBuilder) this;
+ }
+
+ /**
+ * The default operation to perform.
+ *
+ * The option is a:
+ * <code>org.apache.camel.component.statestore.StateStoreOperations</code> type.
+ *
+ * Group: producer
+ *
+ * @param operation the value to set
+ * @return the dsl builder
+ */
+ default StateStoreEndpointBuilder operation(org.apache.camel.component.statestore.StateStoreOperations operation) {
+ doSetProperty("operation", operation);
+ return this;
+ }
+ /**
+ * The default operation to perform.
+ *
+ * The option will be converted to a
+ * <code>org.apache.camel.component.statestore.StateStoreOperations</code> type.
+ *
+ * Group: producer
+ *
+ * @param operation the value to set
+ * @return the dsl builder
+ */
+ default StateStoreEndpointBuilder operation(String operation) {
+ doSetProperty("operation", operation);
+ return this;
+ }
+ /**
+ * Time-to-live in milliseconds for entries. 0 means no expiry.
+ *
+ * The option is a: <code>long</code> type.
+ *
+ * Default: 0
+ * Group: producer
+ *
+ * @param ttl the value to set
+ * @return the dsl builder
+ */
+ default StateStoreEndpointBuilder ttl(long ttl) {
+ doSetProperty("ttl", ttl);
+ return this;
+ }
+ /**
+ * Time-to-live in milliseconds for entries. 0 means no expiry.
+ *
+ * The option will be converted to a <code>long</code> type.
+ *
+ * Default: 0
+ * Group: producer
+ *
+ * @param ttl the value to set
+ * @return the dsl builder
+ */
+ default StateStoreEndpointBuilder ttl(String ttl) {
+ doSetProperty("ttl", ttl);
+ return this;
+ }
+ }
+
+ /**
+ * Advanced builder for endpoint for the State Store component.
+ */
+ public interface AdvancedStateStoreEndpointBuilder
+ extends
+ EndpointProducerBuilder {
+ default StateStoreEndpointBuilder basic() {
+ return (StateStoreEndpointBuilder) this;
+ }
+
+ /**
+ * Whether the producer should be started lazy (on the first message).
+ * By starting lazy you can use this to allow CamelContext and routes to
+ * startup in situations where a producer may otherwise fail during
+ * starting and cause the route to fail being started. By deferring this
+ * startup to be lazy then the startup failure can be handled during
+ * routing messages via Camel's routing error handlers. Beware that when
+ * the first message is processed then creating and starting the
+ * producer may take a little time and prolong the total processing time
+ * of the processing.
+ *
+ * The option is a: <code>boolean</code> type.
+ *
+ * Default: false
+ * Group: producer (advanced)
+ *
+ * @param lazyStartProducer the value to set
+ * @return the dsl builder
+ */
+ default AdvancedStateStoreEndpointBuilder lazyStartProducer(boolean lazyStartProducer) {
+ doSetProperty("lazyStartProducer", lazyStartProducer);
+ return this;
+ }
+ /**
+ * Whether the producer should be started lazy (on the first message).
+ * By starting lazy you can use this to allow CamelContext and routes to
+ * startup in situations where a producer may otherwise fail during
+ * starting and cause the route to fail being started. By deferring this
+ * startup to be lazy then the startup failure can be handled during
+ * routing messages via Camel's routing error handlers. Beware that when
+ * the first message is processed then creating and starting the
+ * producer may take a little time and prolong the total processing time
+ * of the processing.
+ *
+ * The option will be converted to a <code>boolean</code> type.
+ *
+ * Default: false
+ * Group: producer (advanced)
+ *
+ * @param lazyStartProducer the value to set
+ * @return the dsl builder
+ */
+ default AdvancedStateStoreEndpointBuilder lazyStartProducer(String lazyStartProducer) {
+ doSetProperty("lazyStartProducer", lazyStartProducer);
+ return this;
+ }
+ /**
+ * The backend to use. If not set, auto-discovers a single
+ * StateStoreBackend from the registry, or falls back to an in-memory
+ * store.
+ *
+ * The option is a:
+ * <code>org.apache.camel.component.statestore.StateStoreBackend</code>
+ * type.
+ *
+ * Group: advanced
+ *
+ * @param backend the value to set
+ * @return the dsl builder
+ */
+ default AdvancedStateStoreEndpointBuilder backend(org.apache.camel.component.statestore.StateStoreBackend backend) {
+ doSetProperty("backend", backend);
+ return this;
+ }
+ /**
+ * The backend to use. If not set, auto-discovers a single
+ * StateStoreBackend from the registry, or falls back to an in-memory
+ * store.
+ *
+ * The option will be converted to a
+ * <code>org.apache.camel.component.statestore.StateStoreBackend</code>
+ * type.
+ *
+ * Group: advanced
+ *
+ * @param backend the value to set
+ * @return the dsl builder
+ */
+ default AdvancedStateStoreEndpointBuilder backend(String backend) {
+ doSetProperty("backend", backend);
+ return this;
+ }
+ }
+
+ public interface StateStoreBuilders {
+ /**
+ * State Store (camel-state-store)
+ * Perform key-value operations against a pluggable state store backend.
+ *
+ * Category: cache
+ * Since: 4.23
+ * Maven coordinates: org.apache.camel:camel-state-store
+ *
+ * @return the dsl builder for the headers' name.
+ */
+ default StateStoreHeaderNameBuilder stateStore() {
+ return StateStoreHeaderNameBuilder.INSTANCE;
+ }
+ /**
+ * State Store (camel-state-store)
+ * Perform key-value operations against a pluggable state store backend.
+ *
+ * Category: cache
+ * Since: 4.23
+ * Maven coordinates: org.apache.camel:camel-state-store
+ *
+ * Syntax: <code>state-store:storeName</code>
+ *
+ * Path parameter: storeName (required)
+ * The name of the state store
+ *
+ * @param path storeName
+ * @return the dsl builder
+ */
+ default StateStoreEndpointBuilder stateStore(String path) {
+ return StateStoreEndpointBuilderFactory.endpointBuilder("state-store", path);
+ }
+ /**
+ * State Store (camel-state-store)
+ * Perform key-value operations against a pluggable state store backend.
+ *
+ * Category: cache
+ * Since: 4.23
+ * Maven coordinates: org.apache.camel:camel-state-store
+ *
+ * Syntax: <code>state-store:storeName</code>
+ *
+ * Path parameter: storeName (required)
+ * The name of the state store
+ *
+ * @param componentName to use a custom component name for the endpoint
+ * instead of the default name
+ * @param path storeName
+ * @return the dsl builder
+ */
+ default StateStoreEndpointBuilder stateStore(String componentName, String path) {
+ return StateStoreEndpointBuilderFactory.endpointBuilder(componentName, path);
+ }
+
+ }
+ /**
+ * The builder of headers' name for the State Store component.
+ */
+ public static class StateStoreHeaderNameBuilder {
+ /**
+ * The internal instance of the builder used to access to all the
+ * methods representing the name of headers.
+ */
+ public static final StateStoreHeaderNameBuilder INSTANCE = new StateStoreHeaderNameBuilder();
+
+ /**
+ * The operation to perform.
+ *
+ * The option is a: {@code
+ * org.apache.camel.component.statestore.StateStoreOperations} type.
+ *
+ * Group: producer
+ *
+ * @return the name of the header {@code StateStoreOperation}.
+ */
+ public String stateStoreOperation() {
+ return "CamelStateStoreOperation";
+ }
+ /**
+ * The key to use for the operation.
+ *
+ * The option is a: {@code String} type.
+ *
+ * Group: producer
+ *
+ * @return the name of the header {@code StateStoreKey}.
+ */
+ public String stateStoreKey() {
+ return "CamelStateStoreKey";
+ }
+ /**
+ * Per-message TTL override in milliseconds. Takes precedence over the
+ * endpoint ttl option.
+ *
+ * The option is a: {@code Long} type.
+ *
+ * Group: producer
+ *
+ * @return the name of the header {@code StateStoreTtl}.
+ */
+ public String stateStoreTtl() {
+ return "CamelStateStoreTtl";
+ }
+ }
+ static StateStoreEndpointBuilder endpointBuilder(String componentName, String path) {
+ class StateStoreEndpointBuilderImpl extends AbstractEndpointBuilder implements StateStoreEndpointBuilder, AdvancedStateStoreEndpointBuilder {
+ public StateStoreEndpointBuilderImpl(String path) {
+ super(componentName, path);
+ }
+ }
+ return new StateStoreEndpointBuilderImpl(path);
+ }
+}
\ No newline at end of file
diff --git a/dsl/camel-kamelet-main/src/generated/resources/camel-component-known-dependencies.properties b/dsl/camel-kamelet-main/src/generated/resources/camel-component-known-dependencies.properties
index 7f74f6315391..ff1945209f70 100644
--- a/dsl/camel-kamelet-main/src/generated/resources/camel-component-known-dependencies.properties
+++ b/dsl/camel-kamelet-main/src/generated/resources/camel-component-known-dependencies.properties
@@ -366,6 +366,7 @@ org.apache.camel.component.springrabbit.SpringRabbitMQComponent=camel:spring-rab
org.apache.camel.component.sql.SqlComponent=camel:sql
org.apache.camel.component.sql.stored.SqlStoredComponent=camel:sql
org.apache.camel.component.ssh.SshComponent=camel:ssh
+org.apache.camel.component.statestore.StateStoreComponent=camel:state-store
org.apache.camel.component.stax.StAXComponent=camel:stax
org.apache.camel.component.stitch.StitchComponent=camel:stitch
org.apache.camel.component.stream.StreamComponent=camel:stream
diff --git a/parent/pom.xml b/parent/pom.xml
index dd6688d43115..b15f96a5135d 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -2831,6 +2831,26 @@
<artifactId>camel-ssh</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-state-store</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-state-store-caffeine</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-state-store-infinispan</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-state-store-redis</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-stax</artifactId>
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/MojoHelper.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/MojoHelper.java
index 4d798e49d2b0..bd1cb8dfcf7c 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/MojoHelper.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/MojoHelper.java
@@ -74,6 +74,9 @@ public final class MojoHelper {
return Collections.singletonList(dir.resolve("camel-fhir-component"));
case "camel-infinispan":
return Arrays.asList(dir.resolve("camel-infinispan"), dir.resolve("camel-infinispan-embedded"));
+ case "camel-state-store":
+ return Arrays.asList(dir.resolve("camel-state-store"), dir.resolve("camel-state-store-caffeine"),
+ dir.resolve("camel-state-store-redis"), dir.resolve("camel-state-store-infinispan"));
case "camel-azure":
return Arrays.asList(dir.resolve("camel-azure-eventhubs"), dir.resolve("camel-azure-storage-blob"),
dir.resolve("camel-azure-storage-datalake"), dir.resolve("camel-azure-cosmosdb"),