Hi Sorry for posting a question so similar to other ehcache replication problems but I've been banging my head on this most of the day and I've read a lot of stackoverflow posts without a solution.
I've attempted to set up the simplest ehcache replication test possible and it's not working. EhcacheTest writes one element into a cache named "tprc" then reads the cache and prints what it finds. EhcacheTest2 is nearly identical but writes a different element. I'm expecting EhcacheTest2 to show both values, the one written by EhcacheTest and EhcacheTest2.
Here's EhcacheTest:
public class EhcacheTest {
public static void main(String[] args) {
CacheManager manager = CacheManager.newInstance("bin/ehcache.xml");
Cache cache = manager.getCache("tprc");
Element element = new Element("name1", "jim");
cache.put(element);
for (int i = 1; i <= 2; i++) {
String key = "name" + Integer.toString(i);
Element got = cache.get(key);
if (got != null) {
System.out.println("1 " + got.getObjectKey() + "=" + got.getObjectValue());
}
}
}
}
Here's EhcacheTest2:
public class EhcacheTest2 {
public static void main(String[] args) {
CacheManager manager = CacheManager.newInstance("bin/ehcache.xml");
Cache cache = manager.getCache("tprc");
Element element = new Element("name2", "erik");
cache.put(element);
for (int i = 1; i <= 2; i++) {
String key = "name" + Integer.toString(i);
Element got = cache.get(key);
if (got != null) {
System.out.println("2 " + got.getObjectKey() + "=" + got.getObjectValue());
}
}
}
}
And here's the ehcache.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd"
updateCheck="true" monitoring="autodetect"
dynamicConfig="true">
<cacheManagerPeerProviderFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
properties="peerDiscovery=automatic,
multicastGroupAddress=230.0.0.1,
multicastGroupPort=4446"/>
<cacheManagerPeerListenerFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
properties="hostName=192.168.1.115, port=40001, socketTimeoutMillis=5000"/>
<cache name="tprc"
maxEntriesLocalHeap="10"
eternal="false"
timeToIdleSeconds="100"
timeToLiveSeconds="100">
<cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
properties="replicateAsynchronously=false, replicatePuts=true,
replicatePutsViaCopy=true, replicateUpdates=true,
replicateUpdatesViaCopy=true, replicateRemovals=true"/>
</cache>
</ehcache>
I run EhcacheTest, leave it running, then run EhcacheTest2. The output for EhcacheTest is:
1 name1=jim
and the output for EhcacheTest2 is:
2 name2=erik
I want the output for EhcacheTest2 to show
2 name1=jim
2 name2=erik
Does anybody know what's wrong?