davsclaus opened a new pull request, #30152: URL: https://github.com/apache/camel/pull/30152
[CAMEL-27006](https://issues.apache.org/jira/browse/CAMEL-27006) ## Problem Some state stores keep their data only in the memory of the JVM, so the data is lost when the application stops. After a restart a file consumer with `noop=true` reads the same files again, an idempotent consumer with an in-memory repository lets the same messages through again, and an aggregator has lost the groups it was building. Today nothing tells a user, or a tool, which stores are in memory: - The `processor-detail` dev console shows what a route configures, not the defaults. So the default repository of a file consumer with `noop=true` does not show. - JMX does not name the repository of an idempotent consumer or an aggregator. - A class name does not say it either. The Caffeine repositories are in memory, and the key-value repositories of 4.23 are in memory or persistent, depending on the store they delegate to. ## Change - **`org.apache.camel.spi.InMemoryStrategy`** with `boolean isInMemory()`: whether the data is kept only in the memory of this JVM. A store that can be configured either way answers for the configuration in use. A store that does not implement it does not tell. - **Implemented by:** - `MemoryIdempotentRepository`, `MemoryAggregationRepository`, `MemoryKeyValueRepository`, `MemoryStateRepository`, `InMemorySagaService`, and the Caffeine idempotent, aggregation and key-value repositories: `true`. - `KeyValueIdempotentRepository`, `KeyValueAggregationRepository` and `NamespacedKeyValueRepository`: they answer as the store they delegate to. The first two default to an in-memory store when none is set. - **JMX:** - The managed stores have an `InMemory` attribute. - The idempotent consumer has `IdempotentRepositoryClassName` and `IdempotentRepositoryInMemory`. The aggregator has `AggregationRepositoryClassName` and `AggregationRepositoryInMemory`. The `InMemory` attribute is empty when the repository does not tell. - **`processor-detail` dev console:** a processor or route input that keeps state gets a `state` entry: the option, the repository class, and `inMemory` when the repository tells. - Processors: the idempotent consumer and the aggregator, read from their MBeans. - Route input: the `idempotentRepository` and `offsetRepository` options, read through the endpoint's configurer, as camel-console does not depend on the components. So a file consumer with `noop=true` shows the `MemoryIdempotentRepository` it created. - The text output adds "(in memory: lost when the integration stops)". - The generated metadata of the console and its copies in the catalog are updated. A file consumer with `noop=true`: ```json { "id": "from1", "type": "from", "endpointUri": "file://orders?noop=true", "state": [ { "name": "idempotentRepository", "type": "org.apache.camel.support.processor.idempotent.MemoryIdempotentRepository", "inMemory": true } ] } ``` Follow-ups: the configurable caches (Ehcache, JCache, Spring cache, Infinispan), which can compute the answer from their configuration, and the seda endpoint. ## Why now In the local-model benchmark with questions about a running app, "if I restart the app, will it charge the same orders again?" was answered wrong in 5 of 6 answers. The model saw `noop: true` and said that the orders would not be charged again. The processor detail is one of the tools that the AI panel and the MCP server read. ## Tests - `InMemoryStrategyTest` (camel-core): the memory stores say true. The key-value and namespaced repositories answer as their store, also through two delegates, and with no store set. - `ProcessorDetailStateTest` (camel-console, JMX on): an idempotent consumer, a repository that does not tell (no `inMemory`), an aggregator without a repository, a file consumer with `noop=true`, a processor without state, and the text output. - `ManagedMemoryIdempotentConsumerTest` and `ManagedAggregateControllerTest`: the new JMX attributes. - `CaffeineIdempotentRepositoryTest`: the three Caffeine repositories. - The tests above, plus `ProcessorDetailDevConsoleTest`, `ProcessorDetailFromIdTest` and the key-value repository tests: all pass. _Claude Code on behalf of davsclaus_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_016Y4dDi5iQNgtHrDdz2NpwF -- 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]
