【发布时间】:2017-05-18 11:08:25
【问题描述】:
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)
这可能是什么问题。提前致谢。
【问题讨论】:
标签: java transactions timeout ehcache