users@glassfish.java.net

Re: EJB Timing service in Glassfish

From: <glassfish_at_javadesktop.org>
Date: Fri, 12 Sep 2008 06:31:00 PDT

Hi Mamun,

Your best bet is to use this createTimer API :

createTimer(Date initialExpiration, long intervalDuration, Serializable info)

Set the initialExpiration to your start date and the interval to 30 seconds ( converted to milliseconds) . There's no automatic stop time so you'll need to set the end date in the
info object and check it within each timeout callback to know when to cancel the timer.

BTW, we'll have a better way to support this in EJB 3.1 using our new proposed
calendar-based timer expressions. Programmatically it would look something like
this :

    ScheduleExpression sched = new ScheduleExpression();
    // Create a timer that expires every 30 seconds constrained by the given start/end dates
    sched.second("*/30");
    sched.startDate(startDate);
    sched.endDate(endDate);
    
    timerService.createTimer(sched, null);
[Message sent by forum member 'ksak' (ksak)]

http://forums.java.net/jive/thread.jspa?messageID=299039