Activiti workflow engine

1 introduction

Activiti is currently the most widely used open source workflow engine. When we learn Activiti, we need to note that the official Activiti only provides background functions, but does not integrate with the front end, which requires us to integrate ourselves. One of the highlights of learning About Activiti is the 25 tables it provides, followed by some of its apis.

1.1 WorkFolw

Fully automated business processes that transfer documents, information, or tasks between different performers according to a set of ready-made rules. (A completed approval process for a business, e.g., leave, travel)

1.2 the engine

Traditional process approval: state-driven

** Pain points: ** Although it is convenient to develop, the process is complicated to change and modify

** engine: ** automatic processing, decoupling through configuration

Rules engine, expression engine, workflow engine

1.3 Modeling language BPMN

BPM(Business Process Management)

BPMN(Business Process Model And Notation)

A set of symbols describing the various events that occur in a business process.

StartEvent Start EndEvent End

Task {

UserTask UserTask ScriptTask ScriptTask

Service Task Service Task MailTask MailTask

ManualTask task ReceiveTask description task BusinessRuleTask BusinessRuleTask CallActivityTask CallActivityTask

}

SubProcess Lane paths in the SubProcess Pool

Gateway{

ExclusiveGateway ExclusiveGateway InclusiveGateway included gateway EventGateway EventGateway

}

BoundaryEvent boundary IntermediateCatchingEvent intermediate processing events

IntermediateThrowingEvent intermediate events Annotation Annotation

1.4 Activiti usage Steps

  • The introduction of Activiti
  • Define the process
  • Deployment process
  • Start process instance
  • The user queries to-do tasks
  • The user handles the to-do task
  • End of the process

1.5 the characteristics of

  • There can be multiple execution objects in a process, but only one process instance.
  • A process instance is an execution object when the process executes only once according to the rule.

2 Activiti core 25 tables

ACT_RE_*: ‘RE’ stands for repository. This prefixed table contains process definitions and process static resources (images, rules, and so on).

ACT_RU_*: ‘RU’ stands for Runtime. These run-time tables contain running data for process instances, tasks, variables, asynchronous tasks, and more. Activiti saves this data only during the process instance execution and deletes the records at the end of the process. This way the table can stay very small and very fast at runtime.

ACT_ID_*: ‘ID’ stands for identity. These tables contain identity information, such as users, groups, and so on.

ACT_HI_*: ‘HI’ stands for history. These tables contain historical data, such as historical process instances, variables, tasks, and so on.

ACT_GE_*: ‘GE’ stands for general. Common data used in different scenarios, such as storing resource files.

3 Activiti core API

The functions of each Service:

ProcessEngine core ProcessEngine

You can build other classes

RepositoryService Management Process Definition
RuntimeService Perform management, including starting, advancing, and deleting process instances
TaskService Task management
HistoryService History management (management of finished data)
IdentityService Organization management
FormService An optional service, task form management
ManagerService It is almost never used in a custom environment using Activiti. It can query the tables of the database and the metadata of the tables. In addition, it provides the ability to query and manage asynchronous operations.

ProcessDefinition

Process definition class. You can get resource files and so on here.

ProcessInstance

Represents an execution instance of a process definition. If an employee takes a day off, she must issue a request for a process instance. A process instance contains all running nodes. We can use this object to learn information such as the progress of the current process instance. A process instance represents the largest process branch from start to finish of a process, i.e. there is only one process instance in a process.

Execution

Activiti uses this object to describe each node of the process execution. In the absence of concurrency, Execution is the same as ProcessInstance. A process that executes once, according to the rules defined by the process, can indicate the Execution of an object.

4 core Activiti

4.1 Process Variables

BusinessKey business ID

Map<String, Object> Process variables

  • Global variables
  • The Local variable

4.2 the gateway

  • ParallelGateway ParallelGateway

    So all branches are executed, followed by a parallel gateway to aggregate

  • ExclusiveGateway ExclusiveGateway

    Only one branch is selected for execution

  • InclusiveGateway Contains the gateway

    Multiple branches that meet the conditions will be selected for execution, and aggregation will be required later

  • EventGateway indicates the EventGateway