JTA 同步和超时
当使用 Java Transaction API (JTA) 并与当前事务注册同步时,如果事务超时,是否会调用 afterCompletion() 方法?如果是这样,什么时候将调用 afterCompletion() 方法,即当事务运行超过分配的超时值时或当事务超时后发生第一个操作时? status 参数的值是什么(我假设它将是 STATUS_ROLLEDBACK)?
When using the Java Transaction API (JTA) and I register a Synchronization with the current transaction, will the afterCompletion() method be called if the transaction times out? If so, when will the afterCompletion() method be called, i.e. as soon as the transaction runs over the allotted timeout value or when the first operation on the transaction post timeout occurs? What value will the status argument have (I assume it will be STATUS_ROLLEDBACK)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
afterCompletion
方法在事务提交或回滚后调用,因此应该在超时后调用。AFAIK,如果事务在超时值过去之前没有终止(提交或回滚),事务系统将自动回滚它。换句话说,它不会等待事务的后续工作。
我确实会在
afterCompletion
调用时说Status.STATUS_ROLLEDBACK
。The
afterCompletion
method is called after the transaction is committed or rolled back so it ought to be called after a timeout.AFAIK, if a transaction has not terminated (committed or rolled back) before the timeout value elapses, the transaction system will automatically roll it back. In other words, it doesn't wait for subsequent work on the transaction.
I would indeed say
Status.STATUS_ROLLEDBACK
at the time of theafterCompletion
invocation.