I'm trying to reduce the default timeout of 300 seconds with JTA + Atomikos. However, it's not working as it keeps taking 300 seconds to time out.
What I want to do is:
UserTransaction
: Set the timeout to 10 seconds.UserTransactionManager
: Set timeout to 10 seconds.
UserTransactionImp userTransaction = new UserTransactionImp();
userTransaction.setTransactionTimeout(10);
// ...
UserTransactionManager transactionManager= new UserTransactionManager();
transactionManager.setTransactionTimeout(10); // may not be necessary as I do set this on the transaction
// ...
JtaTransactionManager jtaTransactionManager = new JtaTransactionManager(userTransaction,transactionManager);
// ...
TransactionTemplate templ = new TransactionTemplate(jtaTransactionManager, new DefaultTransaction());
templ.execute(callback -> {
// code to update the DB
})
How I am testing this:
- Locking a row via SQLDeveloper,
- Try to update the same row via the app,
- Keeps waiting for the lock,
- Times out eventually.
I expected this to time out after 10 seconds based on the setting I have done above. However, it keeps on waiting for 300 seconds before it times out.
Not sure where else I need to configure this.