9 Replies Latest reply on Apr 3, 2008 11:29 AM by peterj

    jboss scheduler losing time

    mrath

      We have a scheduler which is scheduled to run every day at 11 am. The configuration looks like this:




      false
      myspace.gateway:service=MyConfigMBean

      execute()
      d/MM/yy HH:mm
      24/02/08 11:00
      86400000
      -1
      myspace.gateway:service=MyConfigMBean



      However we notice that the scheduler fires at the wrong time. It lags behind.

      For the first few days after it is deployed, it is firing at 11 am

      Then it is drifting slowly. It schedules at 11.15 am and the next day 11.20 am,11.45,11.55 and so on...

      There is no pattern though.

      Is there anyone who had encountered similar problem before?

      Thanks.



        • 1. Re: jboss scheduler losing time
          mrath

          Sorry, the configuration file looks like :

           <mbean code="org.jboss.varia.scheduler.Scheduler"
           name="netspace.gateway.select:service=SelectGatewayConfigMBeanScheduler">
           <attribute name="StartAtStartup">false</attribute>
           <attribute name="SchedulableMBean">netspace.gateway.select:service=SelectGatewayConfigMBean</attribute>
           <attribute name="SchedulableMBeanMethod">processNSEvent()</attribute>
           <attribute name="DateFormat">d/MM/yy HH:mm</attribute>
           <attribute name="InitialStartDate">24/01/07 11:00</attribute>
           <attribute name="SchedulePeriod">86400000</attribute>
           <attribute name="InitialRepetitions">-1</attribute>
           <depends>netspace.gateway.select:service=SelectGatewayConfigMBean</depends>
           </mbean>
          


          • 2. Re: jboss scheduler losing time
            genman

            What's going on is the time taken to run the task is added on to that period.

            I suggest you use this instead:
            http://wiki.jboss.org/wiki/Wiki.jsp?page=QuartzSchedulerIntegration

            which is more reliable and has "cron"-like scheduling features and is more robust.

            Or, you could come up with a bug+patch that fixes the drift. It'd be an easy feature to add.

            • 3. Re: jboss scheduler losing time
              dimitris

              http://jira.jboss.com/jira/browse/JBAS-3282

               <mbean code="org.jboss.varia.scheduler.Scheduler"
               name=":service=Scheduler">
              ...
               <attribute name="FixedRate">true</attribute> <!-- HERE -->
               </mbean>
              


              • 4. Re: jboss scheduler losing time
                mrath

                Thanks very much for the quick replies.

                <attribute name="FixedRate">true</attribute>


                is really helpful to configure.

                But we are using the jboss version 4.0.4 GA and it does not support this attribute 'FixedRate'. This is being supported from the version 4.0.5.

                • 5. Re: jboss scheduler losing time
                  dvinge

                  Yes, we have had the same problem.

                  The issue is a jboss / jdk problem.

                  The underlying timer you are using are probably from the jdk and not the one from jboss.

                  The Jdk one, does not use fixedrate, so if your code takes 10 sec to run, then the scheduler will run 10 sec later. (I think we found out that this only applys to jdk6, but I'm not sure)

                  I have fixed this by extending the jdk timer, and override the addNotification (the one with 6 arguments), and then calling the super method (the one with 7 argument) allowing you to specify wheater to use fixedrate or not.

                  And then specifying this timer in your mbeans:


                  ...
                  ...
                  jboss:service=TimerMyTimer

                  • 6. Re: jboss scheduler losing time
                    dvinge




                    ...
                    ...
                    jboss:service=TimerMyTimer

                    • 7. Re: jboss scheduler losing time
                      dvinge



                      ...
                      jboss:service=TimerMyTimer

                      • 8. Re: jboss scheduler losing time
                        dvinge

                        &lt;mbean code="com.company.MyFixedRateTimer" name="jboss:service=TimerMyTimer"/&gt;
                        &lt;mbean code="org.jboss.varia.scheduler.Scheduler" name="com.company:service=MyScheduler"&gt;
                        ...
                        &lt;depends&gt;jboss:service=TimerMyTimer&lt;/depends&gt;
                        &lt;/mbean&gt;

                        • 9. Re: jboss scheduler losing time
                          peterj

                          Use the Code button!