3 Replies Latest reply on Apr 25, 2008 1:05 PM by Norton

    schedulable job blocks other schedulable jobs

    Michael Eibeck Newbie


      I am running a JBoss V4.0.5 GA cluster on a LINUX platform.

      I have two schedulable jobs. The configuration in scheduler-service.xml is as follows:

      <mbean code="org.jboss.varia.scheduler.Scheduler" name="ch.skyguide.aim.schedulable:service=ISUPAgentProxy">
       <attribute name="StartAtStartup">true</attribute>
       <attribute name="SchedulableClass">ch.skyguide.aim.schedulable.agent.isup.ISUPAgentProxy</attribute>
       <attribute name="SchedulableArguments">localhost,8080,localhost,8080</attribute>
       <attribute name="SchedulableArgumentTypes">java.lang.String,java.lang.String,java.lang.String,java.lang.String</attribute>
       <attribute name="InitialStartDate">NOW</attribute>
       <attribute name="SchedulePeriod">60000</attribute>
       <attribute name="InitialRepetitions">-1</attribute>
       <attribute name="FixedRate">true</attribute>
       <mbean code="org.jboss.varia.scheduler.Scheduler" name="ch.skyguide.aim.schedulable:service=ImportNavDataProxy">
       <attribute name="StartAtStartup">true</attribute>
       <attribute name="SchedulableClass">ch.skyguide.aim.schedulable.agent.importnavdata.ImportNavDataProxy</attribute>
       <attribute name="SchedulableArguments">c:/NavDataUpload,c:/NavDataUploadTmp,${jboss.server.log.dir},jnp://zhwtdeibeckml:1099/SDOCIImportApp/ImportNavDataAgentImpl/local</attribute>
       <attribute name="SchedulableArgumentTypes">java.lang.String,java.lang.String,java.lang.String,java.lang.String</attribute>
       <attribute name="InitialStartDate">NOW</attribute>
       <attribute name="SchedulePeriod">180000</attribute>
       <attribute name="InitialRepetitions">-1</attribute>
       <attribute name="FixedRate">true</attribute>

      Both schedulable classes ISUPAgentProxy and ImportNavDataProxy are deployed in the same jar-archive in the <jboss dir>/server/default/lib directory. This is to ensure that the schedulable jobs are started automatically with jboss server startup.

      Both schedulable classes ISUPAgentProxy and ImportNavDataProxy
      call stateless session beans which perform the actual job. The call is done like this:

      InitialContext ic = new InitialContext();
       ImportNavDataAgent importNavDataAgent =
       (ImportNavDataAgent) ic.lookup(urlString);

      The schedulable class ImportNavDataProxy looks up a stateless session bean ImportNavDataAgent which performs a task that can take up to 2 hours.

      I have the effect that this long running job blocks the whole scheduler (also other scheduled jobs) until the task is finished.

      This effect is highly undesirable.
      How can I trigger a job from inside a schedulable class which then runs independently of the scheduler? The scheduler is not supposed to wait for the termination of the job and carry on with its work in the sense of "fire and forget".

      Who can help?

        • 1. Re: schedulable job blocks other schedulable jobs
          Norton Newbie

          I am having this same issue. Could someone please reply to this thread?

          Thank you.

          • 2. Re: schedulable job blocks other schedulable jobs
            Michael Eibeck Newbie


            in the meantime I have created my own solution to the problem.

            Both schedulable classes now call the stateless session beans in separate threads. The actual work is done in the new threads. The scheduler thread terminates without waiting for the working threads.

            It works, the scheduler now is no longer blocked by long running jobs.

            Here's the sample code:

            public class ImportNavDataProxy implements Schedulable {
             private String _pathNavData;
             private String _pathNavDataTmp;
             private String _logDataPath;
             private String _jndiNameImportNavDataAgent;
             private static final Logger _logger = Logger.getLogger(ImportNavDataProxy.class.getName());
             public ImportNavDataProxy(String pathNavData, String pathNavDataTmp, String logDataPath, String jndiNameImportNavDataAgent) {
             _pathNavData = pathNavData;
             _pathNavDataTmp = pathNavDataTmp;
             _logDataPath = logDataPath;
             _jndiNameImportNavDataAgent = jndiNameImportNavDataAgent;
             * Method called by the Scheduler
             * @param date Date of the notification call
             * @param remainingRepetitions Number of remaining repetitions
             public void perform(Date date, long remainingRepetitions) {
             // start ImportNavDataAgent in separate thread and terminate this thread immediately.
             // Do not wait for termination of thread.
             ImportNavDataRunner importNavDataRunner = new ImportNavDataRunner();
             Thread t = new Thread(importNavDataRunner);
             public class ImportNavDataRunner implements Runnable{
             public void run(){
             try {
             //replace "localhost" with "serverName"
             InetAddress localMachine = InetAddress.getLocalHost();
             String serverName = localMachine.getHostName();
             String urlString = _jndiNameImportNavDataAgent.replaceAll("localhost", serverName);
             InitialContext ic = new InitialContext();
             ImportNavDataAgent importNavDataAgent =
             (ImportNavDataAgent) ic.lookup(urlString);
            // (ImportNavDataAgent) ic.lookup("jnp://"+localHostName+":1099/SDOCIImportApp/ImportNavDataAgentImpl/local");
             _logger.info("EJB ImportNavDataAgent found.");
             } catch (Exception e) {
             _logger.info("EJB ImportNavDataImpl cannot be found. ("+e.getMessage()+")");
             } /* end of class ImportNavDataRunner */

            • 3. Re: schedulable job blocks other schedulable jobs
              Norton Newbie

              Thanx for the prompt reply. We had thought about forking the process out, but we'd rather see the Scheduler work "correctly."

              It doesn't make sense to us why the Scheduler would wait until a process finishes before starting another one. It seems like an obvious thing to want to run more than one scheduled process at a time.