Michael Barker
Michael Barker

Reputation: 14398

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

Upvotes: 3

Views: 1072

Answers (1)

Pascal Thivent
Pascal Thivent

Reputation: 570645

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.

Upvotes: 2

Related Questions