The determineRemainingTransactionTimeOutPeriod method has rounding off error as it divides by 1000 and type casts the result to int.
If the transaction timeout is set to 1 sec, this method will always return remaining seconds as 0. A better fix is not to divide by 1000 and use long type for determining the timeout in ms.
Also, if possible it should through a sub-class TransactionTimeoutException of TransactionException, similar to
org.springframework.transaction.TransactionTimedOutException. Now, the only way to determing if the transaciton has been timedout programatically is to check for that string in the exception message.