Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time

Build a workflow

Create an activity

An activity is a single unit of process that takes inputs and produces outputs. The Activity interface defines the exact behavior of an activity.

In order to create a new activity, the simplest way is to create a class that extends AbstractActivityWithStateManagement. This abstract class hides all the complexity related to state, inputs and outputs management as well as error handling. It only requires the sub-class to implement the doRun(Context) method, which is then called each time the activity is executed.

The following example shows a simple HelloWorld activity:

About the execution context

As shown in the example above, the doRun method takes a Context instance as parameter. This instance represents the context of the execution and can be used, among other things, to:

  • set/get global variables
  • cancel the execution

The following activity prints different sentence depending on whether the execution has been cancelled:

Provide inputs and outputs

An activity's inputs and outputs can be accessed through the inputs and outputs methods.

The following example shows how to create an AplusB activity that:

  • has two inputs called a and b of type double
  • has one output called c of type double
  • set c to the value of a + b

Inputs and outputs can also be assigned to fields for more convenience:

From lambda expressions

Alternatively, the Activity interface provides factory methods allowing to creates activities from lambda methods:

Bind activities

Configure execution order

The execution order of two activities can be specified through a predecessor/successor relationship. A predecessor is always executed before its successor.

This relationship can be created via the precede and succeed methods:

Bind outputs to inputs

Outputs and inputs must be connected in order to share data between activities. An input can be connected to another data by calling the Input.bind(Data) method.

Create a sequence of activities

Usually successors and predecessors must be executed sequentially. A Sequence is a composite activity that owns a root activity and which, when run, executes its root activity then all its successors and the successors of the successors and so on.

One can be created as follows:

Create parallel activities

A Parallel Split is a composite activity that executes its own activities concurrently.

Once can be created as follows:

Create loop of activities

A Structured Loop is a composite activity that executes another activity until a specified pre or post condition is verified.

One can be created as follows: