9 Replies Latest reply on Dec 17, 2007 1:31 PM by peterj

    need help with scheduler

    bb_app

       

      
      <server>
      
       <mbean code="org.jboss.varia.scheduler.Scheduler"
       name="jboss.docs.chap10:service=Scheduler">
       <attribute name="StartAtStartup">true</attribute>
       <attribute name="SchedulableClass">org.jboss.chap10.ex2.ExSchedulable</attribute>
       <attribute name="SchedulableArguments">TheName,123456789</attribute>
       <attribute name="SchedulableArgumentTypes">java.lang.String,long</attribute>
      
       <attribute name="InitialStartDate">NOW</attribute>
       <attribute name="SchedulePeriod">60000</attribute>
       <attribute name="InitialRepetitions">-1</attribute>
       </mbean>
      
      </server>

      on this code, how can i make the scheduleperiod 7 days?


        • 1. Re: need help with scheduler
          peterj

          Looks like it is in milliseconds. So you need to enter:

          1000 (milli/sec) x 60 (sec/hr) x 24 (hr/day) x 7 (day/week)

          Got a calculator handy?

          • 2. Re: need help with scheduler
            bb_app

            thanks a lot for the reply. But, read somewhere the max is 36000. Tried to change it. But, didn't run. Any clue?

            • 3. Re: need help with scheduler
              peterj

              I looked in the source. There is no such restriction (as far as I can tell).

              • 4. Re: need help with scheduler
                bb_app

                Thnx peter... now it works .... but, do you know how to make it work on a particular day of the week.. say.. particularly monday or tuesday......?

                Is there sth that I can add to the code??

                • 5. Re: need help with scheduler
                  peterj

                  To do this, you will have to do date arithmetic. Get the current time, convert to milliseconds, get the scheduled date, convert to milliseconds, and then subtract the two. The result is what to set SchedulePeriod to.

                  This is so much easier in .Net which provides classes and methods to do date arithmetic.

                  • 6. Re: need help with scheduler
                    bb_app

                    I think you got my question wrong. All I want is to start the scheduler on a particular day every week....there isn't just one scheduled date. This should go on every week.

                    any clue?

                    • 7. Re: need help with scheduler
                      peterj

                      Try this. As an example, to schedule each Monday at noon:

                      Set initialStartDate to "12/17/2007 12:00" (use a valid date string for your locale)

                      Set schedulePeriod to 1 week (in milliseconds, of course)

                      That should work if you start the server today (at least in my time zone). But if you restart the server in a week or two, I don't know if it will automatically adjust the start time based on the period, I could not tell from a casual reading of the source code. My suggestion is to try it with an old date, maybe adding some logging statements to the code, and see what happens in that case. After all, you have the full source code for the scheduler class. And if it doesn't work right. you can always change the code.







                      • 8. Re: need help with scheduler
                        bb_app

                        Peter, thanks for the quick reply ... I appreciate that.. I suggested the same and they dont want it that way. All I need is to set it to a particular day ... say .. ask the scheduler to run every monday or tuesday... They say they want it that way so that they can change it with ease and also monitor only on that particular day of the week...so i dont think I can use the date format...

                        Have you any idea ?? I tried to find a sol. ...and I couldn't

                        • 9. Re: need help with scheduler
                          peterj

                          I already hinted at a possible solution - modify or extend the existing scheduler class to do what you want. It should be relatively simple.