我将Ehcache 2.10.6与SpringBoot 2.0.8.RELEASE结合使用,并具有以下配置在VM之间复制缓存:
<cacheManagerPeerProviderFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
properties="peerDiscovery=automatic, multicastGroupAddress=${ip.address}, multicastGroupPort=${multicst.port}, timeToLive=32, hostName=${hostname}"
propertySeparator=","/>
<cacheManagerPeerListenerFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
properties="hostName=${hostname}, port=${listen.port}, socketTimeoutMillis=120000"
propertySeparator=","/>
使用以下DEBUG日志,复制从一开始就可以正常工作,并在一段时间后停止工作:
rmiUrl is stale. Either the remote peer is shutdown or the network connectivity has been interrupted. Will be removed from list of remote cache peers
我发现heartBeatStaleTime
的默认值为((2 * HeartBeatInterval) + 100)ms
,但我不知道如何使用ehcache配置或SpringBoot更改它。有什么想法吗?
对于感兴趣的人来说,要更改默认值,可以使用以下静态方法:MulticastKeepaliveHeartbeatSender#setHeartBeatStaleTime
但是,即使增加了heartBeatStaleTime
时间,我仍然获得了rmiUrl is stale
DEBUG日志。在此discussion of 2012中,他们说这是网络问题,我不知道该如何解决:(