Lightweight asynchronous tasks

Last modified 22 Apr 2021 17:31 +02:00

Normally, asynchronous tasks are quite heavyweight: they are stored in repository and are managed by Quartz. However, there are situations where we want to quickly create asynchronous tasks for auxiliary reasons, like parallel import, parallel reconciliation, and (in the future) parallel provisioning. And this leads us to the concept of lightweight asynchronous tasks.

They are characterized by the following:

  1. They are transient, i.e. not persistent.

  2. Instead of traditional registered task handler, characterized by its URI, these tasks have a lightweight task handler, which is simply a Runnable.

For the sake of simplicity, lightweight asynchronous tasks (LATs) have currently the following major limitations:

  1. Each LAT always has a persistent task as its parent.

  2. A LATs handler executes only during the execution of a parent task - i.e. all children LATs handlers must finish before parent’s Quartz job execution routine finishes. This ensures that no special code is necessary e.g. on node shutdown.

  3. The set of states for such a task is limited (see below).

  4. LATs are not visible in listSubtasks/listSubtasksDeeply methods. They cannot be used as dependents or prerequisite tasks.

Other minor limitations are:

  1. LAT is always a single-run (not recurring).

  2. ThreadStopAction is not applicable to LATs, because after its thread is stopped, LAT is automatically closed.

  3. Binding is not applicable as well. It could be said that LATs are tightly-bound to the node on which they were started.

States for a LAT:

  1. When created, it is in the RUNNABLE state, with handler not executing.

  2. When the start() method is called, handler is submitted to execution. (This is currently not modeled by the state; in a similar way as traditional tasks do not have separate RUNNABLE / RUNNING states.)

  3. After execution of the handler, the state changes to CLOSED.

  4. Other states (WAITING and SUSPENDED) are not used.

Future:

  1. The rule of mandatory persistent parent disallows use of LATs to support parallel provisioning. This will be changed in the future.

Was this page helpful?
YES NO
Thanks for your feedback