开发者

How JTA/JTS handle transaction time out issue?

开发者 https://www.devze.com 2023-04-06 00:41 出处:网络
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

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?

Application Server iterates through all the transactions to check timeout. If a transaction timeout occurs, application server marks roll back for the tr开发者_高级运维ansaction, 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.

==========

Test Case 1: Set transaction timeout to 10 secs

I. Transaction begin

II. Sleep 20 secs

III. System out "Sleep end"

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

==========

Test Case 2: Set transaction timeout to 10 secs

I. Transaction begin

II. Sleep 20 secs

III. Access db 1st time

IV. Access db 2nd time

V. System out "Sleep end"

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.

==========

Test Case 3: Set transaction timeout to 10 secs

I. Transaction begin

II. Access db and db deadlock

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..

In my understanding, above behavior should be the same while using spring transaction management(JTA) and EJB. Am I right?

Thanks for ur help!


Tested, and proved that my understand should be correct.

Summarize the result as below:

• 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 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号