Related Documentation : Ehcache Replication Guide : Replicated Caching Using RMI : Configuring Cache Replicators
Configuring Cache Replicators
Each cache that will be replicated needs to set a cache event listener which then replicates messages to the other CacheManager peers. This is done by adding a cacheEventListenerFactory element to each cache's configuration.
<!-- Sample cache named sampleCache2. -->
<cache name="sampleCache2"
maxEntriesLocalHeap="10"
eternal="false"
timeToIdleSeconds="100"
timeToLiveSeconds="100"
overflowToDisk="false">
<cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
properties="replicateAsynchronously=true, replicatePuts=true, replicateUpdates=true,
replicateUpdatesViaCopy=false, replicateRemovals=true "/>
</cache>
class - use net.sf.ehcache.distribution.RMICacheReplicatorFactory
The factory recognises the following properties:
*replicatePuts=true | false - whether new elements placed in a cache are replicated to others. Defaults to true.
*replicateUpdates=true | false - whether new elements which override an element already existing with the same key are replicated. Defaults to true.
*replicateRemovals=true - whether element removals are replicated. Defaults to true.
*replicateAsynchronously=true | false - whether replications are asyncrhonous (true) or synchronous (false). Defaults to true.
*replicateUpdatesViaCopy=true | false - whether the new elements are copied to other caches (true), or whether a remove message is sent. Defaults to true.
To reduce typing if you want default behaviour, which is replicate everything in asynchronous mode, you can leave off the RMICacheReplicatorFactory properties as per the following example:
<!-- Sample cache named sampleCache4. All missing RMICacheReplicatorFactory properties
default to true -->
<cache name="sampleCache4"
maxEntriesLocalHeap="10"
eternal="true"
overflowToDisk="false"
memoryStoreEvictionPolicy="LFU">
<cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"/>
</cache>
Copyright © 2010-2015 Software AG, Darmstadt, Germany.

Product Logo |   Feedback