3 Replies Latest reply on Nov 30, 2011 12:38 PM by António Ribeiro

    Multiple Scheduling - "n" times a day, every day

    António Ribeiro Newbie

      Hey guys,

       

      I'm trying to develop a job scheduler that is suppose to run "n" times a day, every day, but I don't know if the configs that I've done are the right ones... Am I missing something here?

       

      This is my scheduler-service.xml file:

       

      <?xml version="1.0" encoding="UTF-8"?> 
      <server>
              <mbean code="org.jboss.mx.timer.JBossTimer"
                          name="jboss:service=Timer">
                </mbean>
      
                <mbean code="workers.SchedulerMonitor" 
                          name="Workers:name=SchedulerMonitorAppServer">
                </mbean>
                <mbean code="org.jboss.varia.scheduler.Scheduler" 
                          name="Workers:service=SchedulerMonitorAppServer,name=SchedulerMonitorAppServerScheduler">
                          <attribute name="StartAtStartup">true</attribute>
                          <attribute name="SchedulableMBean">Workers:name=SchedulerMonitorAppServer</attribute>
                          <attribute name="SchedulableMBeanMethod">printHelloWorld()</attribute>
                          <attribute name="DateFormat">yyyy-MM-dd HH:mm:ss</attribute>
                          <attribute name="InitialStartDate">2011-11-25 15:35:00</attribute>
                          <attribute name="SchedulePeriod">5000</attribute>
                      <attribute name="InitialRepetitions">3</attribute>
                      <attribute name="FixedRate">true</attribute>
                </mbean>
      </server>
      

       

      Grateful for your attention.

       

      Best regards.

        • 1. Re: Multiple Scheduling - "n" times a day, every day
          Venkat Sudheer Reddy Aedama Newbie

          Take a look at Quartz Scheduler.

           

          http://www.quartz-scheduler.org/

           

          I will prefer to have my own Quartz scheduler than the one that ships with JBoss. You may not need the service.xml anymore!

          • 2. Re: Multiple Scheduling - "n" times a day, every day
            António Ribeiro Newbie

            Venkat,

             

            Thank you so much for the tip!

            It is really a good choice but I'll try to dig a little bit further for an answer for my scheduler-service.xml problem.

             

            Because it doesn't make any sense to have a scheduler that only runs or once a day or "n" times in only one day, right?! This functionality should also provide the possibility of using schedulers that operate every day, "n" times a day... Or am I being too greedy?

            • 3. Re: Multiple Scheduling - "n" times a day, every day
              António Ribeiro Newbie

              I've finally adopted the solution of having another instance of the service I wanted:

               

              <?xml version="1.0" encoding="UTF-8"?>
              <server>
                      <mbean code="org.jboss.mx.timer.JBossTimer"
                                  name="jboss:service=Timer">
                        </mbean>
              
                        <mbean code="workers.SchedulerMonitor" 
                                  name="Workers:name=SchedulerMonitorAppServer">
                        </mbean>
                        <mbean code="org.jboss.varia.scheduler.Scheduler" 
                                  name="Workers:service=SchedulerMonitorAppServer,name=SchedulerMonitorAppServerScheduler">
                                  <attribute name="StartAtStartup">false</attribute>
                                  <attribute name="SchedulableMBean">Workers:name=SchedulerMonitorAppServer</attribute>
                                  <attribute name="SchedulableMBeanMethod">printHelloWorld()</attribute>
                                  <attribute name="DateFormat">yyyy-MM-dd HH:mm:ss</attribute>
                                  <attribute name="InitialStartDate">2011-11-30 11:30:00</attribute>
                                  <attribute name="SchedulePeriod">86400000</attribute>
                              <attribute name="InitialRepetitions">-1</attribute>
                              <attribute name="FixedRate">true</attribute>
                        </mbean>
              
              
                        <mbean code="org.jboss.varia.scheduler.Scheduler"
                                  name="Workers:service=SchedulerMonitorAppServer,name=SchedulerMonitorAppServerScheduler2">
                                  <attribute name="StartAtStartup">false</attribute>
                                  <attribute name="SchedulableMBean">Workers:name=SchedulerMonitorAppServer</attribute>
                                  <attribute name="SchedulableMBeanMethod">printHelloWorld()</attribute>
                                  <attribute name="DateFormat">yyyy-MM-dd HH:mm:ss</attribute>
                                  <attribute name="InitialStartDate">2011-11-30 11:35:00</attribute>
                                  <attribute name="SchedulePeriod">86400000</attribute>
                              <attribute name="InitialRepetitions">-1</attribute>
                              <attribute name="FixedRate">true</attribute>
                        </mbean>
              </server>
              
              
              

               

              This way, replicating the services, I can have n schedulers, even though I think code replication shouldn't be the best approach.

              If someone has another idea please let me know... On the meanwhile I'm stiking with this solution!

               

              Grateful for your attention.

               

              Best regards.