• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

difference between userTransaction.rollback() & userTransaction timeout

 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am using stateful session bean and BMT to manage my transaction. I am keeping an open transaction in one of my method. I am expecting the user to call a second method to commit/rollback the transaction. Now, If the user doesn't call the second method, I am setting the transaction timeout. I want the transaction to be discarded if the user doesn't call the second method by 5 seconds. I am expecting the same behavior as the rollback(). Now, though my transaction times out, it doesn't release the locks on db / other resources like it does in case of roll back. Now, What is the difference between timeout and rollback? How can I discard my transaction if user doesn't call the second method??(should i use timer service!!)

regards,
Sajid
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When it Times Out, doesn't it throw an Exception. Then you can just Catch the Exception and roll it back. right?

Mark
 
Sajid Moinuddin
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
methodA(){
UserTransaction ut = sessionContext.getUserTransaction();
ut.setTimeout(5);
ut.begin();

//do some work here

}

methodB(){
UserTransaction ut = sessionContext.getUserTransaction();

//do some work here


ut.commit(); / ut.rollback();
}

I don't get any exception when the transaction times out. Is it supposed to throw any? Where exactly am i supposed to get the exception??
In the stateful session bean, in my method A , the transaction begins & remains open. In method B, the transaction is supposed to rollback/commit. I am keeping an open transaction across methods. That's not a good idea, I know. But I have to do this.
I am expecting if the user doesn't call method B & commits/rollbacks, withing 5 seconds, the transaction be rolled back. But the transaction is not rolling back & holds the lock on database & other resource if user doesn't call method B.

I am using Jboss & mysql. Is this some bug of jboss?? Or my concept is wrong??
regards,
Sajid


I am using Jboss. Is my concept
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic