-
1. Re: Transaction timeouts....bug?
modjoe23 Jun 22, 2006 4:45 PM (in response to modjoe23)I know that I can change the default timeout value from the default 300 seconds in jta-service.xml but I am looking to change the transaction timeout for this transaction only. I've also read the spec but with no luck.
Anybody out there?? Please help! -
2. Re: Transaction timeouts....bug?
marklittle Jun 23, 2006 6:31 AM (in response to modjoe23)Depends what API you're using, but both JTA and OTS have a setTransactionTimeout (or set_timeout) method that operates on the current thread and transactions it creates from that point on. Check the JBossTS manuals (or the JTA/OTS specifications) for more details.
-
3. Re: Transaction timeouts....bug?
modjoe23 Jun 26, 2006 5:38 PM (in response to modjoe23)Thanks.
So I take it there is no way to do it using annotations? -
4. Re: Transaction timeouts....bug?
stone_42 Nov 7, 2007 4:38 AM (in response to modjoe23)"mark.little@jboss.com" wrote:
Depends what API you're using, but both JTA and OTS have a setTransactionTimeout (or set_timeout) method that operates on the current thread and transactions it creates from that point on. Check the JBossTS manuals (or the JTA/OTS specifications) for more details.
In http://wiki.jboss.org/wiki/Wiki.jsp?page=TransactionTimeout there is a good description how to do it.
The page also says that the timeout I set will apply to all transactions started after the setting on the same thread.
Now, the ejbs in my application are called from a Web Application and as we know, Tomcat uses thread pools, so the thread on which I set the transaction timeout will be reused very often and in contexts I do not know and probably I don't want to have the special timeout set for one method executed anywhere in the history of the thread.
So I wonder if there is a possibility to reset the transaction timeout on the executing thread to the default value, as I don't want to set the value every time I start a new transaction anywhere in my code.
I tried to find out looking at the code of JBossTS4.2.3sp5 and found that the transaction timeout is stored in a hashtable (com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction._timeouts) with the thread's id as key and never is removed from that hashtable.
Did I miss where the transaction timeout is reset or is it just not reset anywhere? -
5. Re: Transaction timeouts....bug?
adinn Nov 7, 2007 7:01 AM (in response to modjoe23)You are right that the hashtable does not get cleared. However, setting the value to 0 does ensure that the default timeout is used next time round i.e.*logically* it clears the table.
The simplest solution to your problem is to do the work yourself but *only in the long-running method*. Save the existing timeout at transaction begin then reset to your desired value. At commit restore the original value -- if you know it will always be 0 then there is no need to save at begin, just reset to 0. n.b. if the code following the begin might raise an exception then ensure the reset happens by using a try finally. -
6. Re: Transaction timeouts....bug?
marklittle Nov 7, 2007 7:29 AM (in response to modjoe23)Yes, as Andrew points out, a timeout of 0 is the same as not setting a timeout. It does not mean that there is no timeout associated with the transaction, only that it is implementation dependant. I believe (from memory) the text we used when writing the standards was something like "no application specific timeout is set".
-
7. Re: Transaction timeouts....bug?
obfuscator Nov 20, 2007 3:06 PM (in response to modjoe23)I just got the transaction timeout on an MDB to work, by using BMT and ut.setTransactionTimeout(...).
Using CMT, it doesn't seem like @TransactionTimeout works, nor using TransactionAttribute.NEVER or NOT_SUPPORTED, I still get timeouts. Is this expected behaviour? Are transactions already started when control enters onMessage? Is this why it doesn't work? I tried to set @TransactionTimeout on both the bean class itself and on "onMessage". I'm still puzzled as to why NEVER and NOT_SUPPORTED doesn't work.
While performing the tests, I used 4.2.2-GA, and used StrictMaxPool with one instance and timeout set to Long.MAX_VALUE.
Thanks -
8. Re: Transaction timeouts....bug?
adinn Nov 22, 2007 4:09 AM (in response to modjoe23)
Using CMT, it doesn't seem like @TransactionTimeout works, nor using TransactionAttribute.NEVER or NOT_SUPPORTED, I still get timeouts. Is this expected behaviour? Are transactions already started when control enters onMessage? Is this why it doesn't work? I tried to set @TransactionTimeout on both the bean class itself and on "onMessage". I'm still puzzled as to why NEVER and NOT_SUPPORTED doesn't work.
As Mark confirmed in a previous note: when a transaction client fails to set a tmeout or sets a zero timeout then an implementation-specific interpretation is adopted, In the case of the JBoss JTA this means the timeout property configured form the JBoss transaction properties (600 seconds unless you reset it) is used as the timeout value.
You might like to take this to the EJB forum and ask them why they don't set a timeout value of Integer.MAX_VALUE when a bean specifies NEVER or NOT_SUPPORTED. You had probably better consult a language lawyer first :-)
(n.b. the limit has to be from Integer rather than Long because the timeout supplied in seconds has to be convertible to a timeout in machine time units -- it's still long enough to mean NEVER for all practical purposes)