Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JTA Synchronization and Timeouts

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)?

like image 467
Michael Barker Avatar asked Feb 04 '26 22:02

Michael Barker


1 Answers

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?

The afterCompletion method is called after the transaction is committed or rolled back so it ought to be called after a timeout.

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?

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.

What value will the status argument have (I assume it will be rolled back)?

I would indeed say Status.STATUS_ROLLEDBACK at the time of the afterCompletion invocation.

like image 61
Pascal Thivent Avatar answered Feb 07 '26 10:02

Pascal Thivent



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!