【发布时间】:2018-07-04 17:42:07
【问题描述】:
我在同一台主机上运行 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 Distributed Caching documentation 中提供的默认值:
<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" />
谢谢
【问题讨论】:
标签: java replication rmi ehcache multicast