gnodet opened a new pull request, #25818:
URL: https://github.com/apache/camel/pull/25818

   _Claude Code on behalf of gnodet_
   
   ## Summary
   
   Follow-up to #25631 that introduced the unified `KeyValueRepository` SPI. 
This adds technology-specific implementations for two "medium complexity" 
backends as outlined in the follow-up plan:
   
   ### RedisKeyValueRepository (`camel-redis`)
   - Backed by Redisson client (same library used by the existing 
`RedisAggregationRepository`)
   - **TTL mapping**: milliseconds → `Duration`-based Redis key expiry via 
`RBucket.set(value, Duration)`
   - **Serialization**: Redisson's built-in codec (MarshallingCodec / Java 
serialization)
   - **Atomic putIfAbsent**: via `RBucket.setIfAbsent(value, Duration)`
   - **Key namespacing**: configurable `keyPrefix` (default `camel-kvr:`) to 
isolate entries from other data in the same Redis instance
   - **Key scanning**: uses non-deprecated `KeysScanOptions`-based API for 
`keys()` and `size()`
   - Supports externally-managed `RedissonClient` injection (lifecycle not 
managed) or auto-creation from `endpoint` config
   
   ### InfinispanRemoteKeyValueRepository (`camel-infinispan`)
   - Backed by HotRod client (same approach as existing 
`InfinispanRemoteIdempotentRepository`)
   - **TTL mapping**: milliseconds → Infinispan native lifespan via 
`BasicCache.put(key, value, lifespan, TimeUnit.MILLISECONDS)`
   - **Serialization**: Infinispan's built-in ProtoStream marshaller (String, 
Integer, Boolean etc. work out of the box)
   - **Return values**: uses `Flag.FORCE_RETURN_VALUE` to ensure `put()` and 
`delete()` return previous values per the `KeyValueRepository` contract
   - **Atomic putIfAbsent**: via `BasicCache.putIfAbsent()` (natively atomic in 
Infinispan)
   - Reuses `InfinispanRemoteManager` and `InfinispanRemoteConfiguration` for 
connection lifecycle
   
   ### How it works
   
   With either implementation registered as a bean, all three Camel patterns 
auto-discover and share it:
   
   ```java
   @BindToRegistry("kvRepo")
   public KeyValueRepository kvRepo() {
       return new RedisKeyValueRepository("localhost:6379");
       // or: new InfinispanRemoteKeyValueRepository("my-cache");
   }
   ```
   
   - **State Store component** → uses it directly
   - **Idempotent Consumer EIP** → wraps in `KeyValueIdempotentRepository`
   - **Aggregator EIP** → wraps in `KeyValueAggregationRepository`
   
   No explicit wiring needed.
   
   ## Test plan
   
   - [x] `RedisKeyValueRepositoryIT` — integration tests against real Redis 
(CRUD, TTL expiry, putIfAbsent atomicity, key prefix isolation, custom client, 
size, endpoint validation)
   - [x] `InfinispanRemoteKeyValueRepositoryIT` — integration tests against 
real Infinispan server (CRUD, TTL expiry, putIfAbsent, size, cache name 
validation)
   - [x] Both use existing Testcontainers-based test infrastructure 
(`RedisServiceFactory`, `InfinispanServiceFactory`)
   - [ ] CI build
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
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