有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何验证EHCache的多播自动发现缓存复制是否正常工作?

我已经设置了EHCache,并提供了关于如何设置多播的建议:

<cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
    properties="peerDiscovery=automatic, multicastGroupAddress=230.0.0.1, multicastGroupPort=4446"/>
<cacheManagerPeerListenerFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory" 
    properties="port=40001, socketTimeoutMillis=2000"/>

然后我在两台机器上启动我的应用程序。我如何才能看到它们是否相互发现并使彼此的缓存失效

干杯

尼克


共 (2) 个答案

  1. # 1 楼答案

    似乎仅仅启用它并不会使缓存分布。对于每个缓存,添加如下内容:

       <cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory" properties="replicateAsynchronously=true, replicatePuts=true, replicateUpdates=true, replicateUpdatesViaCopy=true, replicateRemovals=true"/>
       <bootstrapCacheLoaderFactory class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory" properties="bootstrapAsynchronously=true, maximumChunkSizeBytes=5000000"/>
    

    然后它开始滴答作响

  2. # 2 楼答案

    您是否尝试过查看EhCache生成的日志记录?这似乎是一个好的开始