• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 412
  • Last Modified:

How to cancel an EJB transaction?

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
0
undata
Asked:
undata
1 Solution
 
thanassisCommented:
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
      getNextTimeout();
   public javax.ejb.TimerHandle
      getHandle();
   public java.io.Serializable
      getInfo();
}
If a timer is cancelled, the ejbTimeout() method is not called.
0
 
kennethxuCommented:
which version of ejb are we talking about? ejb timer is only aviable in ejb 2.1, which is still in beta spec.
0
 
undataAuthor Commented:
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.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
gopnik5Commented:
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.
0
 
kennethxuCommented:
well, I agree.
0
 
kennethxuCommented:
but undata can use it opposite. a timer under control from ejb2.1
0

Featured Post

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now