我有一个 Jboss Wildfly 8.0.0 集群,有一个主服务器和一个从服务器。 Ehcache 配置为使用手动选项进行 RMI 复制。
问题是复制仅发生在一个方向。从主 Jboss 到从属 Jboss 的复制工作正常。 从属 Jboss 到主 JBoss 没有复制。
我使用 Jconsole 验证缓存详细信息,并且可以看到单向复制。我可以看到在主服务器和从服务器中都创建了缓存,问题是单向复制。
我的主Jboss位于VM Windows server 2012中,从属JBoss位于Windows 8.0桌面上 我在 JBoss 控制台中没有看到任何错误。
在Master ehcache.xml上:
<cacheManagerPeerProviderFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
properties="peerDiscovery=manual,
rmiUrls=//myslave:40002/userAddress"/>
<cacheManagerPeerListenerFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
properties="port=40001,
socketTimeoutMillis=30000"/>
<cache name="userAddress" eternal="true" overflowToDisk="true" maxEntriesLocalHeap="1" memoryStoreEvictionPolicy="LRU" >
<cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
properties="replicateAsynchronously=true, replicatePuts=true, replicateUpdates=true,
replicateUpdatesViaCopy=false, replicateRemovals=true "/>
</cache>
在从属 ehcache.xml 上:
<cacheManagerPeerProviderFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
properties="peerDiscovery=manual,
rmiUrls=//mymaster:40001/userAddress"/>
<cacheManagerPeerListenerFactory
class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
properties="port=40002,
socketTimeoutMillis=30000"/>
<cache name="userAddress" eternal="true" overflowToDisk="true" maxEntriesLocalHeap="1" memoryStoreEvictionPolicy="LRU" >
<cacheEventListenerFactory
class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
properties="replicateAsynchronously=true, replicatePuts=true, replicateUpdates=true,
replicateUpdatesViaCopy=false, replicateRemovals=true "/>
</cache>
最佳答案
主 JBoss 服务器上的防火墙阻止了到主服务器的复制。问题已解决。 值得一读this article在类似的情况下,它提供了有关“remoteObjectPort”的更多想法。
关于java - Ehcache RMI 复制仅以一种方式工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26736805/