【问题标题】:Ehcahe - RMI cache replication - newly added object not displayed in UIEhcache - RMI 缓存复制 - 新添加的对象未显示在 UI 中
【发布时间】:2012-07-03 14:13:52
【问题描述】:

我对@9​​87654321@ 比较陌生,并试图在我的应用程序(示例应用程序)中实现缓存。我目前正在尝试使用 RMI 复制对某些数据对象使用缓存复制。我在同一台机器上运行了 2 个 tomcat 实例,并且在两个实例上都部署了相同的应用程序。我已经验证在检索对象缓存时正确命中并且它正在提高性能。

但是当我在第一个实例上创建一个新对象并尝试在第二个实例中检索(有一个列出所有对象的页面)时,不会显示新添加的对象。

我可以看到该对象在第二个实例的缓存中。此外,在日志中也得到了确认,其中我看到了以下消息

2012-07-03 17:06:41,471 [RMI TCP Connection(6)-192.168.100.105] 调试分发。RMICachePeer - 缓存 com.mycompany.session.Session 的 RMICachePeer:远程放置已接收。元素是:[key = com.mycompany.session.Session#10, value=Item{version=0,freshTimestamp=5494027884412928, version=1, hitCount=0, CreationTime = 1341315402000, LastAccessTime = 1341315402000]

以前有没有人见过这种行为,他们可以帮助我了解可能出了什么问题吗?

下面提到的是我的 ehcache.xml 文件的内容

<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="ehcache.xsd" >

<diskStore path="D:\\Cache1"/>

<cacheManagerPeerProviderFactory
    class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
    properties="peerDiscovery=automatic, multicastGroupAddress=230.0.0.1,         hostName=192.168.100.105, multicastGroupPort=4446, timeToLive=32"
/>

<cacheManagerPeerListenerFactory 
    class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
    properties="hostName=192.168.100.105, port=40001, socketTimeoutMillis=5000"
/>

<cache name="com.mycompany.session.Session"
      maxElementsInMemory="100"
      eternal="true"
      overflowToDisk="true">
      <cacheEventListenerFactory 
            class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
            properties="replicateAsynchronously=false
                       replicatePutsViaCopy=true,
                       replicateUpdatesViaCopy=true,
                       replicatePuts=true,
                       replicateUpdates=true,
                       replicateRemovals=true"/>
      <bootstrapCacheLoaderFactory 
        class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"/>
</cache>

<defaultCache
       maxElementsInMemory="100"
       eternal="true"
       overflowToDisk="true"
/>

</ehcache>

tomcat 的第二个实例也有类似的 ehcache 配置,只是 diskStore 路径是“D://Cache2”,对等侦听器端口是 40002。

感谢您的帮助。

【问题讨论】:

    标签: ehcache


    【解决方案1】:

    看起来您没有在 cacheManagerPeerProviderFactory 中设置端口号。我们应该在 server2 设置上采取其他方式吗?

    <cacheManagerPeerListenerFactory class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
        properties="hostName=localhost, port=50001,socketTimeoutMillis=2000"/>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-02
      • 2015-03-27
      • 1970-01-01
      • 2019-02-09
      • 2013-07-01
      • 2017-05-09
      • 1970-01-01
      相关资源
      最近更新 更多