This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Timer Services in EJb 3.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Timer Services in EJb 3.0" Watch "Timer Services in EJb 3.0" New topic
Author

Timer Services in EJb 3.0

Amar Deep Singh Chaudhary
Ranch Hand

Joined: Dec 26, 2006
Posts: 49
hi
ranchers

i have written a Ejb Timer in the Ejb 3.0. I want to know that where this timer is registered in the Application and how i can change the time of invocation of the method. When i change the time in my code it does't make any effect on scheduler. I am using J Boss 4.0.0GA as application Server.


Amar Deep Singh Chaudhary amardeep@amardeep.100webspace.net


"A thinking mind never dies"
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Hi Amar,

The timers are usually stored in memory and can be persisted to a table (if that's how you have it configured in Jboss). Can you post the part of the code where your are creating the timer and subsequently scheduling it?


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Amar Deep Singh Chaudhary
Ranch Hand

Joined: Dec 26, 2006
Posts: 49
hi
i am sending here the code by which i am creating the Timer and The Function Which i am calling By the Timer.

//function to create timer

public void createSheduleMaintenance() throws PisException,Exception
{TimerService timer=ejbContext.getTimerService();
Calendar now=Calendar.getInstance();
timer.createTimer(now.getTimeInMillis()+1*60*1000, 24*60*60*1000,"hi");

}


// method to execute after time expires

@Timeout
public void monitorearing(Timer timer)
{
// my Code to perform some Operation
}
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Just of future reference you should put your code inside [ CODE ][ /CODE ] (remove the spaces to enable the tag) tags.

Take a look at the following line:



When do you think that is going to trigger? (Hint it's a long time from now)

[ September 04, 2008: Message edited by: Martijn Verburg ]
[ September 04, 2008: Message edited by: Martijn Verburg ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Timer Services in EJb 3.0