1 Reply Latest reply on Nov 22, 2005 12:49 PM by milx

    Inaccuracy of Schedulable tasks

    milx

      Hello there
      I have some org.jboss.varia.scheduler.Schedulable tasks, which are supposed to run at different intervals; once an hour, once a day and once a week. Hence I configure them like this (application details emitted):

      <mbean code="org.jboss.varia.scheduler.Scheduler" name="myapp:service=OnceAnHour">
       <attribute name="StartAtStartup">true</attribute>
       <attribute name="SchedulableClass">MyTask1</attribute>
       <attribute name="DateFormat">dd-MM-yy HH:mm</attribute>
       <attribute name="InitialStartDate">01-11-05 07:15</attribute>
       <!-- Run the task every hour, forever -->
       <attribute name="SchedulePeriod">3600000</attribute>
       <attribute name="InitialRepetitions">-1</attribute>
      </mbean>
      
      <mbean code="org.jboss.varia.scheduler.Scheduler" name="myapp:service=OnceADay?>
       <attribute name="StartAtStartup">true</attribute>
       <attribute name="SchedulableClass">MyTask2</attribute>
       <attribute name="DateFormat">dd-MM-yy HH:mm</attribute>
       <attribute name="InitialStartDate">01-11-05 07:30<attribute>
       <!-- Run the task every day, forever -->
       <attribute name="SchedulePeriod">86400000</attribute>
       <attribute name="InitialRepetitions">-1</attribute>
      </mbean>
      
      <mbean code="org.jboss.varia.scheduler.Scheduler" name="myapp:service=OnceAWeek?>
       <attribute name="StartAtStartup">true</attribute>
       <attribute name="SchedulableClass">MyTask3</attribute>
       <attribute name="DateFormat">dd-MM-yy HH:mm</attribute>
       <attribute name="InitialStartDate">01-11-05 07:00<attribute>
       <!-- Run the task every week, forever -->
       <attribute name="SchedulePeriod">604800000</attribute>
       <attribute name="InitialRepetitions">-1</attribute>
      </mbean>
      

      Now, the first time the hourly task is supposed to run, it starts pretty (within seconds) accurately a quarter past the hour, but once it has run a few times, it becomes more and more inaccurate, and often starts half an hour late (or early, not sure), especially when the server is under heavy load. The other tasks are also not started accurately, especially the weekly task, which seems to run at almost random times.

      Is there an explanation for this, or am I doing something wrong? It could look like the second run of a task is started with the time interval calculated from when the first run finished, not when it started. For instance if MyTask1 is first run at 07:15, and uses 30 minutes to do some work, I would still expect the next run to be at 08:15, but could it be 08:45, an hour after it last finished?

      Any help is highly appreciated, I?m running Jboss 4.0.3SP1.
      Regards
      Trygve