JTA / JTS如何处理事务超时问题? [英] How JTA/JTS handle transaction time out issue?

查看:897
本文介绍了JTA / JTS如何处理事务超时问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的理解,JTA / JTS处理事务超时问题。但是我找不到我的文件或材料来支持我的理解。我的理解是对吗?你知道任何材料是指这个问题吗?

Below is my understand that JTA/ JTS handle transaction time out issue. But I cannot find my document or material to back my understand. Is my understand right? Do u know any material is refer to this issue?

应用服务器遍历所有的事务来检查超时。如果发生事务超时,应用程序服务器标记回滚事务,并记录详细信息。 当事务线程继续尝试访问另一个事务资源(如JDBC / JMS)时,实现JTA接口的事务资源将检查回滚先行进一步前进。然后在这时候,RollbackException被抛出。

Application Server iterates through all the transactions to check timeout. If a transaction timeout occurs, application server marks roll back for the transaction, and log down the detail. But Application Server neither throws exception nor interrupts the transaction this moment. When the transaction thread continue to attempt to access another transactional resource (like JDBC/ JMS), the transactional resource which implements JTA interface will check roll back flag first before go further. Then at this moment, RollbackException is thrown.

==========

==========

测试案例1:
将事务超时设置为10秒

Test Case 1: Set transaction timeout to 10 secs

I。交易开始

二。睡眠20秒

III。系统退出睡眠结束

III. System out "Sleep end"

结果:超时发生在第10秒,系统注销超时细节,但不会抛出异常。 睡眠结束将被打印。

Result: Timeout occur at 10th secs, and system out log down the timeout detail, but not throw exception. "Sleep end" will be printed.

==========

==========

测试用例2:
将事务超时设置为10秒

Test Case 2: Set transaction timeout to 10 secs

I。交易开始

二。睡眠20秒

III。访问db第一次

III. Access db 1st time

IV。访问数据库第二次

IV. Access db 2nd time

V。系统退出睡眠结束

V. System out "Sleep end"

结果:超时发生在第10秒,系统输出记录超时细节,但不会抛出异常。异常在访问db第一次时抛出。 睡眠结束将不会打印。

Result: Timeout occur at 10th secs, and system out logs down the timeout detail, but not throw exception. Exception throws while access db 1st time. "Sleep end" will not be printed.

==========

==========

测试案例3:
将事务超时设置为10秒

Test Case 3: Set transaction timeout to 10 secs

I。交易开始

二。访问db和db死锁

II. Access db and db deadlock

结果:超时发生在第10秒,系统注销超时详细信息。没有异常抛出,事务线程被卡住。 所以事务超时控制不能处理db超时问题。我很困惑这个..

Result: Timeout occur at 10th secs, and system out logs down the timeout detail. No exception throws, the transaction thread is stuck. So transaction timeout control cannot handle db timeout issue. I am so confused about this..

根据我的理解,上面的行为应该在使用Spring事务管理(JTA)和EJB时是一样的。我是对的?

感谢您的帮助!

推荐答案

总结如下结果:

•事务超时控制仅影响事务活动(例如:访问DB /发送JMS消息)。

• Transaction timeout control only affects transactional activities (Ex: access DB/ send JMS message).

•应用服务器在超时时不会立即中断当前事务线程,应用服务器只记录细节。超时异常将在事务提交或尝试访问下一个事务活动时抛出。

• Application server do not interrupt current transaction thread immediately while timeout occurs, instead, application server only log down the detail. Timeout exception will throw while transaction commit or attempt to access next transactional activities.

•DB死锁问题无法通过事务超时控制来处理。但是在某些情况下,DB2具有死锁防止机制来释放死锁并回滚事务。

• DB deadlock issue cannot be handled by transaction timeout control. But DB2 have deadlock prevent mechanism to release the deadlock and roll back transaction for some cases.

这篇关于JTA / JTS如何处理事务超时问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆