2011-06-14 47 views
1

我試圖啓用replecated ehcache和由於某種原因,它似乎並沒有工作。複製Ehcache不工作

我ehcache.xml中 -

<?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"> 

    <diskStore path="java.io.tmpdir"/> 

    <transactionManagerLookup class="net.sf.ehcache.transaction.manager.DefaultTransactionManagerLookup" 
           properties="jndiName=java:/TransactionManager" propertySeparator=";"/> 
    <cacheManagerEventListenerFactory class="com.adobe_services.cache.SampleCacheManagerEventListenerFactory" properties="type=counting"/> 
    <cacheManagerPeerProviderFactory 
      class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory" 
      properties="peerDiscovery=automatic, 
         multicastGroupAddress=230.0.0.1, 
         multicastGroupPort=4446, timeToLive=1" 
      propertySeparator="," 
      /> 
    <cacheManagerPeerListenerFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory" 
            properties="hostName=, port=, socketTimeoutMillis="/> 
    <defaultCache 
      maxElementsInMemory="10000" 
      eternal="false" 
      timeToIdleSeconds="120" 
      timeToLiveSeconds="120" 
      overflowToDisk="true" 
      diskSpoolBufferSizeMB="30" 
      maxElementsOnDisk="10000000" 
      diskPersistent="false" 
      diskExpiryThreadIntervalSeconds="120" 
      memoryStoreEvictionPolicy="LRU" 
      statistics="false" 
      /> 

    <cache name="replicatedCache" 
    maxElementsInMemory="5" 
      maxElementsOnDisk="100000" 
      eternal="true" 
      overflowToDisk="true" 
      diskPersistent="true" 
      diskSpoolBufferSizeMB="20" 
      timeToIdleSeconds="3600" 
      timeToLiveSeconds="3600" 
      memoryStoreEvictionPolicy="LFU" 
      transactionalMode="off"> 
     <cacheEventListenerFactory 
       class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"/> 
     <bootstrapCacheLoaderFactory 
     class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory" 
     properties="bootstrapAsynchronously=false, maximumChunkSizeBytes=5000000" 
     propertySeparator="," /> 
    </cache> 

</ehcache> 

當我插入一個緩存值,然後提取它在另一個羣集實例我不能夠得到的對象。我在同一臺機器上使用tomcat集羣。

不知道什麼是錯的。

回答

2

我注意到你的cacheManagerPeerListenerFactory RMICacheManagerPeerListenerFactory屬性是空的,即properties="hostName=, port=, socketTimeoutMillis="

嘗試用適當的服務器實例設置填充它們,看看是否有效。注意到這種情況here可能與您所遇到的情況類似。

-1

如果在本地測試的Ehcache,嘗試:

multicastGroupAddress=127.0.0.1 

但是當你將切換到真正的網絡環境中,再次使用230.0.0.1。我假設230.0.0.1是您的主網絡接口廣播地址,由ifconfigBcast返回值。

+1

我得到這個錯誤 - 「java.net.SocketException:不是多播地址」,如果我嘗試將127.0.0.1設置爲多播地址 – Pushkar 2011-06-20 21:43:26