2 Replies Latest reply on Feb 22, 2011 7:05 AM by juan-manuel.perez

    Concurrent scheduler tasks?

    Kresimir Tonkovic Newbie

      I have two tasks that should be executed at different schedules, so I created to Schedulable classes and deployed two mbeans:

      Task 1 (nightly):

      <server>
       <mbean code="org.jboss.varia.scheduler.Scheduler" name="hr.chipoteka.erp.nightly-tasks:service=Scheduler">
       <depends>jboss.j2ee:service=EJB,jndiName=ejb/NightlyTasksLocal</depends>
      
       <attribute name="StartAtStartup">true</attribute>
       <attribute name="SchedulableClass">hr.chipoteka.erp.server.NightlyTasksBean</attribute>
      
       <attribute name="DateFormat">yyyy-MM-dd HH:mm:ss</attribute>
       <attribute name="InitialStartDate">2006-10-30 21:30:00</attribute>
       <!-- attribute name="SchedulePeriod">60000</attribute -->
       <attribute name="SchedulePeriod">86400000</attribute>
      
       <attribute name="InitialRepetitions">-1</attribute>
       </mbean>
      </server>
      


      And task 2 (every 10 seconds):

      <server>
       <mbean code="org.jboss.varia.scheduler.Scheduler" name="hr.chipoteka.erp.synchronizer:service=Scheduler">
       <depends>jboss.j2ee:service=EJB,jndiName=ejb/SynchronizerLocal</depends>
      
       <attribute name="StartAtStartup">true</attribute>
       <attribute name="SchedulableClass">hr.chipoteka.erp.server.SynchronizerBean</attribute>
      
       <attribute name="DateFormat">yyyy-MM-dd HH:mm:ss</attribute>
       <attribute name="InitialStartDate">2006-11-01 00:00:00</attribute>
       <attribute name="SchedulePeriod">10000</attribute>
      
       <attribute name="InitialRepetitions">-1</attribute>
       </mbean>
      </server>
      


      jboss.app:
      <?xml version="1.0"?>
      
      <jboss-app>
       <module>
       <har>hibernate-service.xml</har>
       </module>
       <module>
       <service>chipoteka-erp-nightly-tasks-scheduler-service.xml</service>
       </module>
       <module>
       <service>chipoteka-erp-synchronizer-scheduler-service.xml</service>
       </module>
      </jboss-app>
      


      Sometimes execution times of these tasks overlap, but instead of being started concurrently, the scheduler starts them one after the other. How do I make them independent of one another and have them started at their schedules concurrently?

        • 1. Re: Concurrent scheduler tasks?
          Elias Ross Master

          There's an attribute called "Timer" (or something similar). Set it to a different name.

          • 2. Re: Concurrent scheduler tasks?
            juan-manuel.perez Newbie

            Well, although late, for the sake of people looking for the same ...

             

            First you read http://community.jboss.org/wiki/Scheduler

             

            Then you try this:

             

            <!-- Task#1 -->

            <mbean code="javax.management.timer.Timer" name="user:service=MyTimer,name=Task1"/>

            <mbean code="org.jboss.varia.scheduler.Scheduler" name="hr.chipoteka.erp.nightly-tasks:service=Scheduler">

            <depends>jboss.j2ee:service=EJB,jndiName=ejb/NightlyTasksLocal</depends>
              <attribute name="StartAtStartup">true</attribute>
            <attribute name="SchedulableClass">hr.chipoteka.erp.server.NightlyTasksBean</attribute>
            <attribute name="DateFormat">yyyy-MM-dd HH:mm:ss</attribute>
            <attribute name="InitialStartDate">2006-10-30 21:30:00</attribute>
            <!-- attribute name="SchedulePeriod">60000</attribute -->
            <attribute name="SchedulePeriod">86400000</attribute>
            <attribute name="InitialRepetitions">-1</attribute>

            <depends>user:service=MyTimer,name=Task1</depends>

            <attribute name="TimerName">user:service=MyTimer,name=Task1</attribute>

            </mbean>

             

            <!-- Concurrent Task#2 -->

            <mbean code="javax.management.timer.Timer" name="user:service=MyTimer,name=Task2"/>

            <mbean code="org.jboss.varia.scheduler.Scheduler" name="hr.chipoteka.erp.synchronizer:service=Scheduler">

            <depends>jboss.j2ee:service=EJB,jndiName=ejb/SynchronizerLocal</depends>
            <attribute name="StartAtStartup">true</attribute>
            <attribute name="SchedulableClass">hr.chipoteka.erp.server.SynchronizerBean</attribute>
            <attribute name="DateFormat">yyyy-MM-dd HH:mm:ss</attribute>
            <attribute name="InitialStartDate">2006-11-01 00:00:00</attribute>
            <attribute name="SchedulePeriod">10000</attribute>
            <attribute name="InitialRepetitions">-1</attribute>

            <depends>user:service=MyTimer,name=Task2</depends>

            <attribute name="TimerName">user:service=MyTimer,name=Task2</attribute>

            </mbean>