我在同一主机上运行 2 个 tomcat 实例。每个实例都运行相同的 Web 应用程序,该应用程序尝试通过 RMI 复制与某些 ehcache 缓存进行通信。我在 ehcache 中使用自动发现配置,因此不必显式定义哪些是主机以及哪些是我想要复制的缓存。 ehcache 实例无法找到彼此并进行通信:
DEBUG (RMIBootstrapCacheLoader.java:211) - cache peers: []
DEBUG (RMIBootstrapCacheLoader.java:133) - Empty list of cache peers for cache org.hibernate.cache.UpdateTimestampsCache. No cache peer to bootstrap from.
如果我尝试同样的事情,但这次在单独的主机(盒子)上运行每个 tomcat 实例,那么一切都会像魅力一样工作。
我是否做错了什么,或者当实例位于同一主机上时,无法通过多播进行自动发现?
我的配置使用中提供的默认值RMI 分布式缓存文档 http://ehcache.org/documentation/distributed_caching_with_rmi.html:
<cacheManagerPeerProviderFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
properties="peerDiscovery=automatic, multicastGroupAddress=230.0.0.1,
multicastGroupPort=4446, timeToLive=32"/>
<cacheManagerPeerListenerFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
properties="port=40001, socketTimeoutMillis=2000"/>
在我想要复制的每个缓存区域内,我有:
<cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
properties="asynchronousReplicationIntervalMillis=500 " />
<bootstrapCacheLoaderFactory
class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory" />
thanks