2 Replies Latest reply on Sep 27, 2010 7:30 PM by Dave Oxley

    Batch processing library - QueuJ

    Dave Oxley Newbie

      I hope this is the correct place to post this. We have recently open sourced a batch processing library that integrates well into Seam.


      Some of the features:

      • Sophisticated concurrency controls by extending QueueRestriction. Default is to run all processes concurrently.

      • Optional persistence with transactional sections so a process will restart from the section that was running after a JVM restart.

      • Scheduling of processes for the future, recurring on a schedule or run immediately with options to catch up on missed runs, run once for any missed runs or forget missed runs.

      • Separate schedule for recovery of failed processes.

      • Configure multiple hierarchical queues with each inheriting properties of the parent queue.

      There is no documentation on the site yet, but there is a sample seam application in the source repository: http://queuj.svn.sourceforge.net/viewvc/queuj/queuJSeamSample/trunk/

      An example of creating a queue with a simple QueueRestriction in an initialisation bean:

      public class Initialiser {
          public Queue<SeamProcessBuilder> DEFAULT_QUEUE;
          public Queue<SeamProcessBuilder> SAMPLE_QUEUE;
          public void init() {
              QueueBuilder<SeamProcessBuilder> qb = DEFAULT_QUEUE.newQueueBuilder();
              qb.setQueueRestriction(new TestQueueRestriction());
              SAMPLE_QUEUE = qb.newQueue();
          public static class TestQueueRestriction extends QueueRestriction {
              protected boolean canRun(Queue queue, Process process) {
                  int running = process.getContainingServer().getProcessIndexes().countOfRunningProcesses(queue);
                  int waiting = process.getContainingServer().getProcessIndexes().countOfWaitingToRunProcesses(queue);
                  return (running + waiting) < 100;

      And an example of running a process with the sample queue:

          public Queue<SeamProcessBuilder> SAMPLE_QUEUE;
          public void runJob1() {
              SeamProcessBuilder pb = SAMPLE_QUEUE.newProcessBuilder(Locale.getDefault());
              pb.setProcessName("Test 1");
              pb.setProcessDescription("Test 1");
              pb.setProcessDetails(TestRunner.class, "run", new Class[] {}, new Object[] {});
              pb.setParameter("random", Math.random());
      public class TestRunner {
          public double random;
          public void run() {

      Hope people find this useful.