How to cancel an EJB transaction?

Posted on 2003-03-27
Medium Priority
Last Modified: 2012-08-13
Can I cancel an EJB transaction without waiting for it to timeout and throw a timeout exception?
Let's say I am performing a database search that takes too long.
I have access to the session bean's handle (I store it on the session).
How can I stop the transaction?

Thanks in advance
Question by:undata
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

thanassis earned 750 total points
ID: 8217832
A bean may cancel the timer before it expires by calling the cancel method on the Timer, which is part of the Timer interface:

public interface javax.ejb.Timer {
   public void cancel();
   public long getTimeRemaining();
   public java.util.Date
   public javax.ejb.TimerHandle
   public java.io.Serializable
If a timer is cancelled, the ejbTimeout() method is not called.
LVL 14

Expert Comment

ID: 8219079
which version of ejb are we talking about? ejb timer is only aviable in ejb 2.1, which is still in beta spec.

Author Comment

ID: 8225759
We are using only EJB1.1 with Oracle's OC4J App. Server.  So we will have to wait a while before we can get these functions.
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Expert Comment

ID: 8226867
Well, this is not exactly what is meant by the question.
The question is about how to CANCEL a transaction, and not how to remove a timeout so it would never be canceled.
So, it’s exactly the opposite.
LVL 14

Expert Comment

ID: 8227264
well, I agree.
LVL 14

Expert Comment

ID: 8227276
but undata can use it opposite. a timer under control from ejb2.1

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The top devops trends for 2017 are focused on improved deployment frequency, decreased lead time for change and decreased MTTR.
If you're a modern-day technology professional, you may be wondering if certifications are really necessary. They are. Here's why.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question