users@glassfish.java.net

EJBTimer bean - scheduled timer date creation. Glassfish build b58g-fcs restart cause timer to become active even creation time is in the past

From: Hilmi Hilmiev <hhilmiev_at_gmail.com>
Date: Mon, 5 May 2008 17:43:03 +0300

Dear All,

I come with one issue, I could not understand or find solution.

I have following EJBTimer issue:

[code]
        Calendar calendar = Calendar.getInstance();
        Calendar calendarSchedule = Calendar.getInstance();
        calendar.setTime(new Date());
        calendarSchedule.clear();
        calendarSchedule.set(calendar.get(Calendar.YEAR),
calendar.get(Calendar.MONTH), calendar.get(Calendar.DATE), 17, 25);

        ctx.getTimerService().createTimer(calendarSchedule.getTime(),
86400000, null);
        Util.logMessage("G-Import Service has been created " + " " +
calendarSchedule.getTime().toString());
[code]

I expect from the above code timer to be created at todays date and at 17:25
as time. If I deploy application it works well, but if I restart server let
say at 18:00 o'clock, timer expires again - so, this cause JMS message to be
send second time, while I need this message once per day. Idea is to have
one service which runs each day once at certain time and to not depend from
server restart or deploy.


Am I doing something wrong?


Thank you in advance for each idea or recommendation!


Your sincerely,
Hilmi