Skip to content
Juha Syrjälä edited this page Jan 29, 2016 · 22 revisions

Workflows terms

Workflow

Workflow is a collection of tasks whose execution is orchestrated in a predefined manner. Tasks can be executed automatically (by computer) or manually (by human). Credit application process is an example of a workflow: it contains tasks starting from receiving the application and ending to granting or declining the loan.

Workflow definition

Workflow definition represents the static structure of a workflow. This includes the order in which tasks are executed and transitions between tasks. Workflow definition is described as a Java class in nFlow.

Workflow instance

Workflow instance is a runtime instance of a workflow definition. For example, receiving credit application from a certain customer starts an instance of credit application workflow.

State

State is a step in a workflow, in which certain task is being executed. State has a type that determines how nFlow will handle it. The state types are:

  • start: New workflow instance can be started from this state.
  • manual: Human action is required for moving to next state.
  • normal: State can be executed automatically according to state method definition.
  • end: State in which workflow instance can be considered finished.

Business key

Business key is defined by the creator of the workflow instance. It is not necessarily unique for each workflow instance. It may be used to link multiple workflow instances that are related to the same domain concept (e.g. account number). The business key is not used by nFlow engine.

ExternalId

ExternalId is a unique identifier of the workflow instance, defined by the creator of the workflow instance. ExternalIds must be unique within the same executor group. nFlow uses ExternalId for implementing idempotent retry pattern: the first received workflow instance with an ExternalId is valid, the following workflow instances are considered duplicates.

State method

State method or state handler method is a method with a specific signature in a workflow definition Java class. The method contains the functionality that is executed when nFlow executes a state. The state and the corresponding method have same name: e.g state createApplication is handled by method public NextAction createApplication(StateExecution e).

Status

Workflow instance status represents the generic processing status of a workflow instance. The status is updated by nFlow engine and cannot be updated through APIs. The status is always one of the following:

  • created: The workflow instance has been created but none of the states has been processed yet by the nFlow engine.
  • inProgress: At least one state of the workflow has been processed by the nFlow engine, and there's more states to be processed.
  • executing: The nFlow engine is currently processing one of the states of the workflow instance.
  • manual: The workflow instance is in a state that requires human action. nFlow engine will not process this instance until it has been updated manually to another state and status.
  • finished: The workflow instance processing has been completed and the instance is in a final state.

Workflow instance action

Every change to the workflow instance is recorded as a workflow instance action. The action tells what happened, when and what triggered the change. There are four types of instance actions:

  • stateExecution: Recorded after normal, successful state execution.
  • stateExecutionFailed: Recorded after normal state execution that resulted in failure.
  • externalChange: Recorded when the workflow instance was updated by user, for example via REST API.
  • recovery: Recorded when another nFlow node continued executing the workflow instance that was locked by another nFlow node. This should happen only if the original nFlow node was shutdown in uncontrolled way.

Deployment terms

Executor group

Executor group contains nFlow nodes that manage the same workflow instances and have the same workflow definitions. They share the same database and monitor each other through database stored heartbeats. For example, you can have executor group for workflows of a single application or business domain.

nFlow node

nFlow node is a Java process that contains at least nFlow engine module and an executor group. An active nFlow node contains workflow definitions and executors. A passive nFlow instance has no executors, but it can be used for monitoring and managing workflow instances.

Executor

Executor is a thread that processes workflow instances inside nFlow node.

Dispatcher

Dispatcher is a thread that loads executable workflow instances from the database and assigns them to executors for processing.

Workflow hierarchy terms

Workflow hierarchy

Workflow instances that belong together but are executed independently by nFlow. Workflow hierarchy consists of one root workflow instance and any number of child workflow instances. For example, a shopping cart delivery workflow could start a child workflow for delivering each shopping cart item.

Root workflow

Root workflow is a workflow instance that can have any number of child workflows but has no parent workflow. The root workflow is not a parent workflow unless it has child workflows.

Parent workflow

Parent workflow is a workflow instance that has one to many child workflows. Parent workflow may also be a child workflow of another workflow instance, except when it is the root workflow of the workflow hierarchy.

Child workflow

Child workflow is a workflow that has a parent workflow. Child workflow may also be a parent workflow, when it has child workflows of it's own. Child workflow has a link to its parent workflow and to the root workflow of the workflow hierarchy.

Advanced terms

Archiving

Workflow instance archiving is a maintenance process that moves finished workflow hierarchies that have been inactive for some time period to archive tables in the database.

Workflow executor listener

Workflow executor listener is a component that can be used to implement business logic common to all workflow types outside workflow state methods, for example for locking or logging purposes. Listeners must implement the WorkflowExecutorListener interface. All registered executor listeners are called by nFlow before (beforeProcessing()) and after (afterProcessing() or afterFailure()) state processing. The process() methods of the registered executor listeners form a chain that calls the next listener by default, but the implementation may break the chain and skip the state method processing by not calling the ListenerChain.next() method. The last listener in the chain is always nFlow's ProcessingExecutorListener that executes the workflow state method.