• Post Reply Bookmark Topic Watch Topic
  • New Topic

Abort Transaction  RSS feed

 
Jeff Storey
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to abort a transaction already in progress (i.e. a method being run by a bean)?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no way a method by itself can be stopped, but if by transaction you mean database transaction, then those can be aborted by calling their rollback method.
 
Jeff Storey
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately, I'm really just looking for a way to kill a long running process. I know the standard way for doing this is to put a flag that gets checked in a loop, i.e. while (isAlive) {...}, but I cannot do this because I am calling a long process from an API (I do not have the source) and also, the main process is not a looping process, it's just one time through a method with several long steps. Is there a way to do this?

Thanks.
Jeff
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you run that call in its own thread, and then check back if the thread has terminated after x seconds? If not, call Thread.stop to make it go away. Thread.stop has problems (as is explained in its javadoc entry), but those would seem not to apply in your situation, where the code is part of a separate library.
 
Jeff Storey
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm doing my best to stay away from Thread.stop. It's deprecation may mean its disappearance from future versions of Java (although I think it's in Java 6). Also though, I shouldn't be spawning threads on the app server as per the ejb spec. I think I found a work-around that will just let the task finish processing but disconnect the client from that task so it no longer receives any updates. Thanks for the help.

Jeff
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!