[jboss-user] [Installation, Configuration & DEPLOYMENT] - Re: schedulable job blocks other schedulable jobs

skymic do-not-reply at jboss.com
Fri Apr 25 10:44:36 EDT 2008


Hi,

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);
  |         t.start();
  | 
  |     }
  | 
  | 
  |     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.");
  | 
  |                 importNavDataAgent.importNavData(_pathNavData,_pathNavDataTmp,_logDataPath);
  | 
  |             } catch (Exception e) {
  |                 _logger.info("EJB ImportNavDataImpl cannot be found. ("+e.getMessage()+")");
  |             }
  | 
  |         }
  | 
  |     }   /* end of class ImportNavDataRunner */
  | 
  | }
  | 



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4146836#4146836

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4146836



More information about the jboss-user mailing list