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

   ## Summary
   
   _Claude Code on behalf of gnodet_
   
   Introduces a new `KeyValueRepository` SPI 
(`org.apache.camel.spi.KeyValueRepository`) that provides a unified key-value 
abstraction to reduce the boilerplate of implementing per-storage-technology 
`IdempotentRepository` and `AggregationRepository` classes.
   
   ### What's included
   
   - **`KeyValueRepository`** interface in `camel-api` — extends `Service`, 
with methods for `get`, `put` (with TTL), `delete`, `contains`, `keys`, 
`clear`, `putIfAbsent`, `size`
   - **`MemoryKeyValueRepository`** in `camel-support` — 
`ConcurrentHashMap`-based implementation with lazy TTL eviction
   - **`KeyValueIdempotentRepository`** adapter in `camel-support` — wraps any 
`KeyValueRepository` as an `IdempotentRepository` using `Boolean.TRUE` as 
marker value
   - **`KeyValueAggregationRepository`** adapter in `camel-support` — wraps any 
`KeyValueRepository` as a `RecoverableAggregationRepository` using 
`DefaultExchangeHolder` for Exchange serialization, with proper recovery 
support (completed-but-unconfirmed entries stored under a separate key prefix)
   - **Auto-discovery** — if no explicit `IdempotentRepository` or 
`AggregationRepository` is configured on the Idempotent Consumer or Aggregator 
EIP, a `KeyValueRepository` from the Camel registry is auto-discovered and 
wrapped with the appropriate adapter (explicit configuration always takes 
precedence)
   - **43 unit tests** covering all new classes: `MemoryKeyValueRepository` (19 
tests), `KeyValueIdempotentRepository` (12 tests), 
`KeyValueAggregationRepository` (12 tests)
   
   ### Design decisions
   
   - The existing `IdempotentRepository` and `AggregationRepository` interfaces 
are **not modified** — the adapters are new classes that wrap a 
`KeyValueRepository`
   - Auto-discovery is a **fallback only** — explicit repository configuration 
always takes precedence
   - All new public classes/interfaces carry `@since 4.23` tags
   
   ### Motivation
   
   Currently, every storage technology (Redis, Hazelcast, Infinispan, Caffeine, 
JDBC, LevelDB, etc.) must implement both `IdempotentRepository` and 
`AggregationRepository` separately, duplicating the same adapter pattern. With 
`KeyValueRepository`, a single implementation per storage technology can serve 
both EIPs through the generic adapters.
   
   ## Test plan
   
   - [x] `MemoryKeyValueRepositoryTest` — 19 tests (TTL expiration, 
put/get/delete/contains/keys/clear/putIfAbsent, different value types)
   - [x] `KeyValueIdempotentRepositoryTest` — 12 tests 
(add/contains/remove/confirm/clear, duplicate detection, factory method)
   - [x] `KeyValueAggregationRepositoryTest` — 12 tests (add/get/remove, 
getKeys, recovery flow: scan/recover/confirm, exchange header preservation)
   - [x] Code formatted with `mvn formatter:format impsort:sort`
   
   🤖 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