Results 1 to 7 of 7

Thread: Declarative tx management and JTA timeout

  1. #1
    Join Date
    Aug 2004
    Posts
    7

    Default 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

  2. #2
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    736

    Default

    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,
    Colin Sampaleanu
    SpringSource - http://www.springsource.com

  3. #3
    Join Date
    Aug 2004
    Posts
    7

    Default

    Hi Colin,

    Thanks for the info. I'll try it out.

    Regards,
    Dave

  4. #4
    Join Date
    Sep 2004
    Posts
    6

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

  5. #5
    Join Date
    Feb 2005
    Posts
    2

    Default 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

  6. #6
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    335

    Default

    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

  7. #7
    Join Date
    Feb 2005
    Posts
    2

    Default 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
  •