Contents

  1. Introduction
  2. Create the queue
  3. Prepare for the loop!
  4. Create the workflow
  5. Understand what is happening

Introduction

Ok, things start to become clearer, but this product is called evQueue, where are these queues? For the moment I've seen none!

Well, in fact you already have used them, but just with the default parameters. evQueue ships with a default queue (well named 'default'). If you take one of your previous workflows and go to the 'Queue & retry' tab of one task, you will see that it is assigned to this default queue.

Queues are used to handle parallelism (if set to a concurrency above 1) or mutual exclusion (if set to a concurrency of 1). These two concepts are very useful for different things:

The example workflow on photo resize (see loops) already uses parallel task execution for the convert script. However, it might not be slow enough for you to see it. So we will simulate a CPU intensive task with a sleep, for demonstration purposes.

Create the queue

Before we start, we need to create a new queue. Go to the Settings -> Queues menu and add a new queue ( icon).

Name it sleep and set a concurrency of 2. The scheduler can be left to 'default'.

Prepare for the loop!

As we said, in most cases parallel tasks are instanciated with loops. So we need something to loop on. Here, we'll use the following shell script:

#!/bin/bash

echo "<root>";
for((i=0;i<10;i++))
do
        echo "<item />";
done
echo "</root>";

Create the script 'loop.sh', put it in you task directory (see the processmanager.tasks.directory directive of the configuration file) and make it executable:

root@evqueue:~# chmod +x loop.sh

Create the workflow

Create a task named 'loop' with an XML output (see loops).

Create a new workflow, name it loopsleep.

In the first job, put the newly created 'loop' task from the task library.

Add a dynamic shell task in a new job (under 'loop') and set its path to '/bin/slep 5'. Go to the 'Queue & retry' tab and choose the 'sleep' queue.

Edit the job containing the sleep task and go to the 'Conditions & loops' tab. Open the helper ( icon) next to the loop input. Set it like this:

You now have the final workflow:

Understand what is happening

The next step is to launch our brand new workflow. It will run for exactly 25s: 2 tasks run simultaneously for 5 seconds, then 2 again... until we reach the 10 instanciated tasks.

There are several things to note here. First, when the instance is running you can see the icon in its status, indicating that some tasks are queued. This means that these tasks have not yet been launched due to concurrency limit on their queue. They will be launched as soon as a running task ends.

If you have a look at the instance detail (while running) you can see that some tasks are already terminated, more specifically 2 tasks are running and the others are queued:

If you hover the icon you'll see the instance status graph:

One more last interesting thing to look is the System state -> Queues screen. You should see something like this: