3.9. Transaction timeouts
You can associate timeout values with transactions in order to control their lifetimes. If the timeout value elapses before a transaction terminates, by committing or rolling back, the transaction system rolls it back. The XAResource
interface supports a setTransactionTimeout
operation, which allows the timeout associated with the current transaction to be propagated to the resource manager and if supported, overrides any default timeout associated with the resource manager. Overriding the timeout can be useful when long-running transactions may have lifetimes that would exceed the default, and using the default timeout would cause the resource manager to roll back before the transaction terminates, and cause the transaction to roll back as well.
If You do not explicitly set a timeout value for a transaction, or you use a value of 0
, an implementation-specific default value may be used. In JBoss Transactions, property value CoordinatorEnvironmentBean.defaultTimeout
represents this implementation-specific default, in seconds. The default value is 60 seconds. A value of 0
disables default transaction timeouts.
Unfortunately, imposing the same timeout as the transaction on a resource manager is not always appropriate. One example is that your business rules may require you to have control over the lifetimes on resource managers without allowing that control to be passed to some external entity. JBoss Transactions supports an all-or-nothing approach to whether or not method setTransactionTimeout
is called on XAResource
instances.
If the JTAEnvironmentBean.xaTransactionTimeoutEnabled
property is set to true
, which is the default, it is called on all instances. Otherwise, use the setXATransactionTimeoutEnabled
method of com.arjuna.ats.jta.common.Configuration
.