繁体   English   中英

使用事务控制器的Ehcache事务超时

[英]Ehcache transaction timeout using transaction controller

ehcache.xml中

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:noNamespaceSchemaLocation="ehcache.xsd" maxBytesLocalHeap="800M">

        <diskStore path="java.io.tmpdir"/>
        <defaultCache eternal="true" overflowToOffHeap="false" overflowToDisk="false" transactionalMode="local"/>

    </ehcache>

我正在使用TransactionController进行事务管理。

 final boolean isLocalTransactionContext = mTransactionManager.getCurrentTransactionContext() == null;
        try {
            if (isLocalTransactionContext) {
                mTransactionManager.begin(10);
            }

Element cacheElement = mCache.get(Key);
return cacheElement;
} finally {
            if (isLocalTransactionContext) {
                mTransactionManager.commit();
            }
        }

当我在缓存中寻找的“键”对象在那里不可用时,它会超时。 理想情况下,它应该只返回“ null”,但会超时。 同样,这并非总是可再现的错误。

et.sf.ehcache.transaction.TransactionTimeoutException: transaction [41] timed out
     net.sf.ehcache.transaction.local.LocalTransactionStore.assertNotTimedOut(LocalTransactionStore.java:108)
     net.sf.ehcache.transaction.local.LocalTransactionStore.get(LocalTransactionStore.java:349)
     net.sf.ehcache.store.AbstractCopyingCacheStore.get(AbstractCopyingCacheStore.java:95)
     net.sf.ehcache.store.TxCopyingCacheStore.get(TxCopyingCacheStore.java:33)
     net.sf.ehcache.Cache.get(Cache.java:1723)
     net.sf.ehcache.Cache.get(Cache.java:1696)

这可能是问题所在。 提前致谢。

因为您说的是这种情况并非总是可重复的,所以我假设您不时地且仅在配置的事务超时(示例中为10秒)到期后才收到此异常。

这可能是并且很可能是完全正常的:如果并发事务正在修改您尝试获取的元素,则当前事务将被阻塞,直到另一个事务提交或回滚为止。 根据并发事务花费的时间,或者如果您有许多事务都争用同一个键,则很有可能其中之一最终会超时。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM