使用 Wildfly,我可以远程监听缓存事件吗?
Using Wildfly, can I listen remotely for cache events?
我将 Wildfly 配置为使用缓存进行休眠,如下所示:
<subsystem xmlns="urn:jboss:domain:infinispan:3.0">
<cache-container name="hibernate" default-cache="local-query" module="org.hibernate.infinispan">
<local-cache name="local-query">
<transaction mode="NON_XA"/>
<eviction strategy="LRU" size="10000"/>
<expiration max-idle="28800000"/>
</local-cache>
<local-cache name="entity">
<transaction mode="NON_XA"/>
<eviction strategy="LRU" size="10000"/>
<expiration max-idle="28800000"/>
</local-cache>
<local-cache name="timestamps">
<transaction mode="NON_XA"/>
<eviction strategy="NONE"/>
</local-cache>
</cache-container>
</subsystem>
我想公开一个 hotrod 端点并以与使用 Infinispan Server 执行此操作的方式非常相似的方式侦听缓存事件。我这样做是因为我正在手动和有选择地复制底层数据库,我也想手动使另一端的 Hibernate 缓存失效。
我该怎么做?
您可以将 hotrod 服务器嵌入到 WildFly 部署中。
您需要从 JNDI 获取 WildFly 缓存管理器,然后使用它启动 HotRodServer。我有一个小项目 [1],它演示了如何设置这样的东西。
[1] https://github.com/tristantarrant/infinispan-playground-embedded-hotrod
我将 Wildfly 配置为使用缓存进行休眠,如下所示:
<subsystem xmlns="urn:jboss:domain:infinispan:3.0">
<cache-container name="hibernate" default-cache="local-query" module="org.hibernate.infinispan">
<local-cache name="local-query">
<transaction mode="NON_XA"/>
<eviction strategy="LRU" size="10000"/>
<expiration max-idle="28800000"/>
</local-cache>
<local-cache name="entity">
<transaction mode="NON_XA"/>
<eviction strategy="LRU" size="10000"/>
<expiration max-idle="28800000"/>
</local-cache>
<local-cache name="timestamps">
<transaction mode="NON_XA"/>
<eviction strategy="NONE"/>
</local-cache>
</cache-container>
</subsystem>
我想公开一个 hotrod 端点并以与使用 Infinispan Server 执行此操作的方式非常相似的方式侦听缓存事件。我这样做是因为我正在手动和有选择地复制底层数据库,我也想手动使另一端的 Hibernate 缓存失效。
我该怎么做?
您可以将 hotrod 服务器嵌入到 WildFly 部署中。 您需要从 JNDI 获取 WildFly 缓存管理器,然后使用它启动 HotRodServer。我有一个小项目 [1],它演示了如何设置这样的东西。
[1] https://github.com/tristantarrant/infinispan-playground-embedded-hotrod