Claus Ibsen created CAMEL-27012:
-----------------------------------

             Summary: camel-ehcache, camel-hazelcast, camel-infinispan, 
camel-jcache, camel-spring - the cache repositories tell whether they keep 
their data only in memory
                 Key: CAMEL-27012
                 URL: https://issues.apache.org/jira/browse/CAMEL-27012
             Project: Camel
          Issue Type: Improvement
          Components: camel-infinispan, camel-jcache, camel-seda, 
camel-ehcache, camel-spring, camel-hazelcast
            Reporter: Claus Ibsen
            Assignee: Claus Ibsen
             Fix For: 4.24.0


Follow-up of CAMEL-27006. That issue added 
org.apache.camel.spi.InMemoryStrategy with the method boolean isInMemory(), and 
implemented it for the stores that are always in memory.

The contract: isInMemory() returns true when the data is kept only in memory, 
so the data is lost when the application stops. False means that the data is 
kept elsewhere, or that the store cannot tell. Only true counts: the tools show 
only true.

The repositories of the configurable caches can be in memory or not, depending 
on their configuration. So they answer for the configuration in use:

* *camel-ehcache* (EhcacheIdempotentRepository, EhcacheAggregationRepository, 
EhcacheKeyValueRepository): from the resource pools of the cache. A persistent 
disk tier or a clustered tier keeps the data. Heap, off-heap, or a disk tier 
that is not persistent loses it. The default, when no configuration is found, 
is heap only.
* *camel-infinispan-embedded* (InfinispanEmbeddedIdempotentRepository, 
InfinispanEmbeddedAggregationRepository): a cache store keeps the data, unless 
it purges on startup. A replicated or distributed cache keeps copies on the 
other nodes. A local cache without a store loses the data. That is the default.
* *camel-hazelcast* (HazelcastIdempotentRepository, 
HazelcastAggregationRepository, ReplicatedHazelcastAggregationRepository, 
HazelcastKeyValueRepository): decided when asked, as the cluster changes. A 
client or a lite member, a MapStore, or data persistence keeps the data. A 
member alone in its cluster loses it. With other members, the backups decide 
(the default backup count of 1 keeps the data). A replicated map has a copy on 
every member.
* *camel-jcache* (JCacheIdempotentRepository, JCacheAggregationRepository, 
JCacheKeyValueRepository): the standard API cannot ask for persistence. A 
write-through cache keeps the data elsewhere. The reference implementation and 
Caffeine JCache keep it in memory. Other providers cannot tell, so false.
* *camel-spring* (SpringCacheIdempotentRepository): ConcurrentMapCache (the 
Spring Boot default) and CaffeineCache are in memory. RedisCache is not. Other 
caches cannot tell, so false.
* *camel-seda*: the messages waiting in the queue of a seda endpoint are lost 
when the application stops.

The repositories of the other components keep their data outside the JVM (JDBC, 
JPA, Cassandra, MongoDB, Redis, Kafka, Infinispan remote), so they need no 
change.

Tests with real caches, no mocks:
* Ehcache: heap only, and a persistent disk tier in a temporary directory.
* Infinispan: a local cache, a file store, a file store that purges on startup, 
and a replicated cache with two embedded nodes.
* Hazelcast: one member, two members, a map with a MapStore, and a client.
* JCache: the reference implementation or Caffeine, with and without 
write-through.
* Spring: ConcurrentMapCacheManager.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to