-
Sep 3rd, 2004, 11:58 AM
#1
Declarative tx management and JTA timeout
Hello,
Can anyone point me to how to set the JTA timeout for a particular method invocationwhen I'm using declarative transaction management?
Regards,
Dave
-
Sep 3rd, 2004, 12:21 PM
#2
For both Spring and JTA transactions, you can set a timeout.
TransactionAttributeEditor is the JavaBeans PropertyEditor that ultimately converts to a TransactionAttriibute from the text form. Unfortunately, the JavaDocs were for some reason missing mentioning the token for the timeout, never mind the fact that many people don't realize this PropertyEditor is actually what defines the string format anyways, and the timeout value was not mentioned in the Spring docs.
Just apply a timeout with a 'timeout_' prefix. So for example,
PROPAGATION_REQUIRED,readOnly,timeout_10
should specify a timeout of 10 seconds (as opposed to the default setting of 'the default for the transaction manager'.
I will update the documentation entry in JIRA to add a note about mentioning the timeout prefix. I have already updated the JavaDoc for TransactionAttributeEditor.
Regards,
-
Sep 3rd, 2004, 01:09 PM
#3
Hi Colin,
Thanks for the info. I'll try it out.
Regards,
Dave
-
Sep 30th, 2004, 01:57 PM
#4
Timeout code
I would *really* like to see some code, if someone has used this feature of the springframework...let me first try to follow this thread before posting a new one.
Let me also state the problem in plain English:
How can I error trap a database lock?
-
Feb 17th, 2005, 03:41 PM
#5
Timeout in transaction is not working
Hi
I have given following value for transactionAttributes --
PROPAGATION_REQUIRED,ISOLATION_READ_COMMITTED,time out_5
I started transaction and using System.currentTimeMillis(), I did transaction to spend time for 6 secs after started transaction. Since time out is 5 secs, it should rollback transaction and should come out of the transaction. But this is not happening. That means timeout is not working properly
Can anybody tell me how to set timeout in spring config file
Thanks in advance....
Thanks
Koti
-
Feb 17th, 2005, 05:43 PM
#6
Koti,
the timeout value should be regarded as advice, not as a strict requirement. AFAIK Spring's internal transaction managers do not enforce timeouts they simply pass the time to live for your transaction on to enlisted resources such as JDBC/Hibernate that can enforce timeouts.
For example - say your transaction has a timeout of 10 seconds and 6 seconds have already elapsed when you execute a query using JdbcTemplate, internally a timeout of 4 seconds (the time to live of the transaction) is applied to the Statement that is used to execute the query (the code for this is found in DataSourceUtils.applyTransactionTimeout()). So if the query takes longer than 4 seconds you should expect that the JDBC driver to throw an exception, however, if the query only takes 3 seconds to complete and your code spends and additional 2 seconds processing the result before you commit the transaction no timeout will occur even though the transaction has taken 11 seconds.
I've not found any problems with this behaviour but if you do need strict transaction timouts you'll probably have to go down the JTA path.
Ollie
-
Feb 18th, 2005, 04:44 PM
#7
Timeout in transaction is not working
Hi oliverhutchison
Thanks for ur quick reply.
I tested with complex update statements, which is taking more than 1 min, without depending on system time delay, I gave timout 1 sec, still I am able to successfully update in db. I do not know how exactly I can test, whether it is problem with db or spring. I am using db2 database. If you have anything in ur mind pls tell me.
Thanks
Koti
Thanks
Koti
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules