davsclaus commented on code in PR #2046:
URL: 
https://github.com/apache/camel-spring-boot/pull/2046#discussion_r4329858898


##########
components-starter/camel-state-store-starter/src/main/doc/usage.adoc:
##########
@@ -0,0 +1,43 @@
+=== Choosing a backend
+
+The State Store component supports Spring Cache and Camel `KeyValueRepository` 
backends.
+
+==== Spring Cache
+
+Set `camel.state-store.spring-cache.enabled=true` to register a 
`StateStoreBackendFactory` backed by Spring's `CacheManager`. Each state-store 
name maps to a Spring cache with the same name, reusing the application's 
`spring.cache.*` configuration.
+
+The factory is registered when a single `CacheManager` candidate is available 
and no other `StateStoreBackendFactory` bean is defined. It does not register a 
global `KeyValueRepository` bean.
+
+==== Camel KeyValueRepository
+
+Alternatively, use a Camel `KeyValueRepository` implementation, such as 
`camel-redis`, `camel-caffeine`, `camel-jcache`, `camel-sql`, or 
`camel-infinispan`. Define the repository as a bean and leave 
`camel.state-store.spring-cache.enabled` disabled. The State Store component 
automatically discovers the repository.
+
+These repositories can also be discovered by Camel features that support 
`KeyValueRepository`, including the Aggregate EIP, Idempotent Consumer, and 
Cache EIP.
+
+==== Configuration examples
+
+To use Spring Cache, configure a cache provider and enable the factory:
+
+[source,properties]
+----
+spring.cache.type=caffeine
+spring.cache.cache-names=orders,users
+camel.state-store.spring-cache.enabled=true
+----
+
+Provide a `CacheManager` bean or configure Spring Boot cache 
auto-configuration. If `spring.cache.cache-names` specifies a fixed set of 
names, include every state-store name you use. A dynamic cache manager can 
create caches on demand.

Review Comment:
   Spring Boot creates the `CacheManager` from `spring.cache.*` only when 
caching is enabled, so the example needs `@EnableCaching` (`spring.cache.type` 
alone does not create one). The suggestion says so:
   
   ```suggestion
   Spring Boot creates the `CacheManager` from `spring.cache.*` only when the 
application enables caching with `@EnableCaching`; otherwise, provide your own 
`CacheManager` bean. Without a single `CacheManager`, the factory is not 
registered and each store falls back to an in-memory repository. If 
`spring.cache.cache-names` specifies a fixed set of names, include every 
state-store name you use. A dynamic cache manager can create caches on demand.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to