• Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB Timer Service? Specifying a time?

 
Fiona Healy
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using CMP beans for a report generating and scheduling application. As a result i need to use the EJB Timer service. I have been doing a bit of reading and discovered that you cant specify a time for the ejbTimeOut() method to execute?

Any ideas for a solution to this problem. I can't really develop a report generating application without giving the user the option to enter in a time???
 
Steve Buck
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.onjava.com/pub/a/onjava/2004/10/13/j2ee-timers.html

This is a good little article that I learned about J2EE timers from.

When you say you want the user to enter a time--do you mean for the report generation/scheduling or the actual EJB timeout for method calls?

If its the former, you can easily do it with this:
createTimer(Date firstDate, long timeoutInterval, Serializable info)

Where timeoutInterval is the milliseconds between calls and firstDate is the initial occurence. When the timeoutInterval is reached, the container will call the ejbTimeout method for you automatically and do your business logic (report generation and scheduling).
 
Fiona Healy
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so by assigning the time of day e.g. 08:00 to the interval which is in miliseconds and passed to the createTimer method, you can specify the time of day that the report is generated?

Am i right?
 
Steve Buck
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Specify the time you would like the first occurence with firstDate and then if you want it everyday at that time, use 24 hours in milliseconds (86400000 I think?) for the timeoutInterval.

You should have a look at the article, though. I'm quite tired so take what I say with a few handfuls of salt
 
Fiona Healy
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats great, i have the article downloading as i type
Thanks.

p.s. get some sleep
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!