0 Replies Latest reply on Jun 10, 2013 11:00 AM by blabno

    Job manager/dispatcher pattern

    blabno Master



      In my app there are some long running tasks that can be started from web front-end. Admin should see progress of those tasks in the same front-end.

      What is the best approach to implement this?


      Right now I have 1 ApplicationScoped JobManager and ~20 task executors running on separate JVM's (simple standalone apps). Those executors periodically (fast) pool JobManager for jobs through JAX-RS.

      JobManager must know which job is executed by which executor so that it's not done twice. Also that information must be persistent (in case of JobManager crash/restart).


      public String assignJob(String executorId) {

          Job job = get1stUnassignedJobFromDB();



          return job.getId();



      The problem is that sometimes executor 1 gets job A, the transaction doesn't get commited yet and the executor 2 also get's the same job.