These docs are for v3.0.2. Click to read the latest docs for v5.

Simple Job

A job that can run in parallel

Simple Jobs are atomic scripts which can be invoked at any point in time from any kind of rules engine scripts or can be configured to start automatically when the platform starts. Simple job will always run on every node (machine) of the cluster. If you have configured 10 job instances during startup, each node will have 10 instances of this job running.

Example: A Job waits on a queue and exits gracefully

def incomingFaceImages = grid.objQueue("IncomingFaceImages");

while(!Thread.currentThread().isInterrupted()){

  def image = incomingFaceImages.poll(30, java.util.concurrent.TimeUnit.SECONDS);

  if(null == image){
    log.info("I did not receive anything in last 30 secs, I am exitting...");
    return;
  }

	//do the image processing here}
}

A Binary Rule posts the face Images to a distributed queue

def MAX_JOBS = 10;
def JOB_ID = "ProcessImageJob";
def incomingFaceImages = grid.objQueue("IncomingFaceImages");
def count = job.count(JOB_ID);

def res = incomingFaceImages.offer(msg.getData());

if(!res){
  log.error("No space left in Q(IncomingFaceImages)");
  //do the error handling here.
}

if(count < MAX_JOBS){
  job.start(JOB_ID); // start 1 instance
  //job.start(JOB_ID, (MAX_JOBS-count)); //start multiple instances
}

if(res) msg.delete(); //delete the raw message (freeup some space)

You can upload the images using Sending Binary Messages