Chapter 20. Process
A process is a named element defined in a process definition. It exists in a knowledge base and is identified by its ID.
A process represents a namespace and serves as a container for a set of modeling elements. it contains elements that specify the execution workflow of a business process or its parts using flow objects and flows. Every process must contain at least one start event and one end event.
A process is accompanied by its BPMN Diagram, which is also part of the process definition, and defines the visualisation of the process execution workflow, for example in the Process Designer.
Apart from the execution workflow and process attributes, a process can define process variables, which store process data during runtime. For more information on process variables, see Section 4.9, “Variables”.
Runtime
During runtime, a process serves as a blueprint for a process instance, similarly to a class and its objects. A process instance is managed by a session, which may contain multiple process instances. This enables the instances to share data, for example, using global variables. Global variables are stored in the session instance, not in the process instance, which enables communication across process instances. Every process instance has its own context and ID.
Knowledge Runtime, called kcontext
, holds all the process runtime data. Use it to retrieve or modify the runtime data, for example in Action Scripts:
Getting the currently executed element instance. You can then query further element data, such as its name and type, or cancel the element instance.
NodeInstance element = kcontext.getNodeInstance(); String name = element.getNodeName();
Getting the currently executed process instance. You can then query further process instance data, such as, its name, ID. You can also abort the process instance, or send an event, such as a Signal Event.
ProcessInstance proc = kcontext.getProcessInstance(); proc.signalEvent(type, eventObject);
Getting and setting the values of variables.
kcontext.setVariable("myVariableName", "myVariableValue");
Execute calls on the Knowledge runtime, for example, start process instances, insert facts, and similar.
kcontext.getKnowledgeRuntime().signalEvent(eventType, data, kcontext.getProcessInstance().getId());
A process instance has the following lifecycle phases:
- CREATED
-
When you call the
createProcessInstance
method on a process, a new process instance is created. The process variables are initialized and the status of the process instance isCREATED
. - PENDING
- When a process instance is created, but not yet started.
- ACTIVE
-
When you call the
start()
method on a process instance, its execution is triggered and its status isACTIVE
. If the process is instantiated using an event, such as Signal, Message, or Error Events, the flow will start on the respective type of start event. Otherwise, the flow starts on the None Start Event. - COMPLETED
-
Once there is no token in the flow the process instance is finished and its status is
COMPLETED
. Tokens in the flow are consumed by End Events and destroyed by Terminating Events. - ABORTED
-
If you call the
abortProcessInstance
method, the process instance is interrupted and its status isABORTED
.
The runtime state of a process instance can be made persistent, for example, in a database. This enables you to restore the state of execution in case of environment failure, or to temporarily remove running instances from memory and restore them later. By default, process instances are not made persistent. For more information on persistence see chapter Persistence of the Red Hat JBoss BPM Suite Administration and Configuration Guide.
Properties
- ID
Process ID defined as a String unique in the parent knowledge base.
Example value:
org.jboss.exampleProcess
.It is recommended to use the ID form
<PACKAGENAME>.<PROCESSNAME>.<VERSION>
.- Process Name
- Process display name.
- Version
- Process version.
- Package
Parent package to which the process belongs (that is process namespace).
The package attribute contains the location of the modeled process in form of a String value.
- Target Namespace
- The location of the XML schema definition of the BPMN2 standard.
- Executable
Enables or disables the process to be instantiated. Set to
false
to disable process instantiation.Possible values:
true
,false
.- Imports
- Comma-separated values of imported processes.
- Documentation
- Contains element description, has no impact on runtime.
- AdHoc
Boolean property defining whether a process is an ad-hoc process.
If set to
true
, the flow of the process execution is controlled exclusively by a human user.- Globals
- Set of global variables visible for other processes to allow data sharing.
- Variable Definitions
- Enables you to define variables available for the process.
- Process Instance Description
- Contains description of the process, has no impact on runtime.
- TypeLanguage
- Identifies a type system used for the process.
- Base Currency
-
Identifies the currency in simulation scenarios. Uses the ISO 4217 standard, for example
EUR
,GBP
, orUSD
.