![](/img/trans.png)
[英]How to separate application Logs in JBoss 7.0 using standalone.xml
[英]Infinispan cache settings set in JBoss EAP 7.0 standalone.xml not reflected in application
我在 JBoss 7 中通过 CLI 添加了一个缓存:
/subsystem=infinispan/cache-container=sample:add
/subsystem=infinispan/cache-container=sample/replicated-cache=account:add(mode=ASYNC)
/subsystem=infinispan/cache-container=sample/replicated-cache=account/component=transaction:write-attribute(name=mode,value=BATCH)
/subsystem=infinispan/cache-container=sample/replicated-cache=account/component=locking:write-attribute(name=isolation, value=REPEATABLE_READ)
看到它反映在 standalone.xml 的 Infinispan 子系统中:
<cache-container name="sample">
<replicated-cache name="account" mode="ASYNC">
<locking isolation="REPEATABLE_READ"/>
<transaction mode="BATCH"/>
</replicated-cache>
</cache-container>
看到它反映在 JBoss 控制台中:
但是在应用程序中使用时,找到了缓存容器,但没有找到缓存。 相反,当使用不同的设置集调用cacheManager#getCache
时,它会延迟创建。
模式集被复制,但找到的是本地的。 交易等其他设置也不同。 我错过了什么?
我和你有非常相似的问题。 我在EAP 7中有一个配置了生命周期的本地缓存。它配置得相对较短。 相同的配置在早期就很好用,但是我们意识到,缓存的内容将永远保留在缓存中。
问题在于我们如何到达缓存实例。 我们注入了缓存管理器:
@Resource(lookup = "java:jboss/infinispan/download-manager")
private CacheContainer cacheContainer;
然后,我们使用缓存容器访问缓存。 调试后,即使EAP 7中的寿命仅为30秒,寿命也为-1。
cacheContainer.getCache("someCache")
没有获取高速缓存的实例,而是使用默认值创建了一个新的高速缓存。 我认为这解释了您的“本地缓存”唯一设置。
我如何使用正确的设置进入缓存:
@Resource(lookup = "java:jboss/infinispan/cache/download-manager/someCache")
private Cache<String, Object> negative_cache_direct;
看起来缓存只是在依赖的 EJB 模块上急切地初始化。 由 CDI 支持的库不会触发缓存初始化。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.