• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Identifying Transaction timeout

 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a SLSB with BMT. In one of the methods of this bean i start a transaction and set a timeout value on this transaction. Now whenever the timeout occurs, a exception(java.lang.Interrupted) is thrown. In case the Interrupted exception is because of transaction timeout, i would like to do some additional logic. Is there any way to identify that the Interrupted exception was because of timeout? I could not find any APIs on the UserTransaction or the InterruptedException, which would tell me that timeout had occured.
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When the time out occurs, I'd expect the transaction to be marked for rollback. You should be able to just check the status of the UserTransaction object.
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I'd expect the transaction to be marked for rollback



The transaction is indeed marked for rollback. But, is there any way through which i can say for sure that this is marked for rollback because of a timeout? The transaction may be marked for rollback for some other reasons as well.
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check your server log.
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, server logs will contain the timedout message. But as i stated:

In case the Interrupted exception is because of transaction timeout, i would like to do some additional logic.



So i would have to know that a timeout has occured, programatically. I went through the code in JBoss(the appserver that i am using) and found that on timeout of a transaction, it logs a WARN message and then invokes thread.interrupt().

This effectively means that the actual cause(timeout) is lost. And i guess,(after looking at the code of JBoss) i wont be able to identify the timeout of a transaction, programatically.
[ February 23, 2006: Message edited by: jaikiran pai ]
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator




The transaction is indeed marked for rollback. But, is there any way through which i can say for sure that this is marked for rollback because of a timeout? The transaction may be marked for rollback for some other reasons as well.



If you catch an InterruptedException *and* check whether the transaction is marked for roll back - you have narrowed it down pretty well isn't it? Isn't that sufficient for you? Granted that each one of these conditions can happen independently( an InterruptedException being thrown and transaction rolling back) for separate reasons. But when they both occur at the same time, you can be pretty sure it *is* what you're looking for.
 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

But when they both occur at the same time, you can be pretty sure it *is* what you're looking for.



You are right, this is a fair enough solution. Thanks a lot.
 
reply
    Bookmark Topic Watch Topic
  • New Topic