Acitiviti theory study notes

Reference blog:

https://blog.csdn.net/lxxiang1/article/details/82262109

http://hackday.cn/info/activiti-5.21/Activiti_manual_cn.htm#_%E7%AE%80%E4%BB%8B

https://doc.yonyoucloud.com/doc/activiti-5.x-user-guide/index.html

https://blog.csdn.net/zezezuiaiya/article/details/78121663

I love you to the point of unselfishness. It's like a dove flying away in a person's hand, he blessed that dove flying from his heart. ----Wang Xiaobo 2020.09.07

Workflow Engine (Workflow Engine)

For example, when developing a system, the most critical part is not the interface of the system, nor the exchange of information with the database, but how to develop program logic that meets actual needs based on business logic and ensure its stability and ease of maintenance (modularization) And structure) and flexibility (easy to make procedural changes based on changes in actual business logic, such as changes in decision-making power, changes in organizational structure, and new business logic due to changes in business direction, etc.). The Workflow engine solves this problem: If the application lacks a powerful logic layer, it will become error-prone (information routing errors, infinite loops, etc.).
It's like a car, no matter how beautiful the exterior is, if there is a problem with the engine, it is just a decoration. The flexibility of the application system is like the performance of the engine speed. It takes 1 hour to accelerate to 100 kilometers (changes in the business process require half a year of program modification). Can a car be called a good car? Do you dare to drive a car whose engine turns off at every turn (the program falls into an infinite loop due to logic problems)?

Introduction to Activiti

Activiti is a project established by the creator of jBPM, Tom Baeyens, after leaving JBoss. It is built on the basis of years of experience accumulated during the development of jBPM versions 1 to 4, and aims to create the next generation of BPM solutions.

Activiti is an open source workflow engine, which implements the BPMN 2.0 specification, can publish the designed process definition, and perform process scheduling through the api.

As an Apache license 工作流和业务流程管理开源平台, Activiti's core is ultra-fast and ultra-stable based on Java BPMN2.0 流程引擎, emphasizing the embeddability and scalability of process services, and more emphasis on business personnel.

The Activiti process engine focuses on the ease of use and lightness of system development. For each BPM business function, the Activiti process engine is provided to developers in the form of services. By using these services, developers can build feature-rich, lightweight and efficient BPM applications.

  • Activiti is a lightweight workflow business management platform for enterprise users, developers, and system administrators.
  • Activiti is released under the ApacheV2 license and can run in any type of Java program such as servers, clusters, cloud services, etc. Activiti can be perfectly integrated with Spring.
  • The design based on minimalism makes Activiti very lightweight.

Features of Activiti

  • 1) 数据持久化
    The design idea of ​​Activiti is simple and fast. Developers who have experience in application development know that the bottleneck of the application is reflected in the process of exchanging data with the database. Aiming at this point Activiti选择了使MyBatis, the Command can be executed through the optimal SQL statement. This alone can keep the engine at the highest speed. Performance.

  • 2)引擎service接口

The Activiti process engine focuses on the ease of use and lightness of system development. Activiti process engine for every BPM business function 以服务的形式提供给开发人员. By using these services, developers can build feature-rich, lightweight and efficient BPM applications.
The ctiviti.cfg.xml file is the core configuration file. The configuration file is integrated in the Spring IOC container to generate a ProcessEngineConfiguration object, which is the configuration object of the process engine, and the ProcessEngine object is the process engine object, which is the workflow business. At the core of the system, all business operations are implemented by objects derived from this object.

The Activiti engine provides seven service interfaces, all of which are obtained through the ProcessEngine, and support the chain API programming style.

  • 3) 流程设计器
    In the jBPM4 era, there is a special Eclipse plug-in that can be used to design jPDL, and the Activiti team also specially designed the Eclipse Designer, a process calculator for designing the BPMN 2.0 specification. In addition, there is a web-based Activiti Modeler process designer customized by Signavio for Activiti. For those who like to use IDEA, IDEA also has actiBPM plug-in support.
  • 4) 原生支持Spring
    Activiti natively supports Spring, which is particularly important for enterprise applications: Spring integration can be easily performed, and it is very convenient to manage transactions and parse expressions (Expression).
  • 5) 分离运行时与历史数据
    Activiti inherits from jBPM4, and also follows the separation of runtime and historical data in the table structure design. This design can quickly read runtime data, and only read from a special historical data table when historical data needs to be queried. . This design method can greatly improve the efficiency of data access, especially when the data accumulates over time, it can still respond quickly.

Activiti architecture and components

[External link image transfer failed, the source site may have an anti-hotlink mechanism, it is recommended to save the image and upload it directly (img-VbfR8XYV-1599219097992)(imgclip.png "imgclip.png")]

  • Activiti Engine:

As the core module, it provides analysis, execution, creation, management (tasks, process instances), query history records and generate reports based on the results of the BPMN 2.0 specification.

  • Activities Modeler

It is a model designer, which was not developed by Activiti, but was presented by Signavio, a recognized company in the industry (Signavio e was originally a charged product, and is now licensed to Activiti users for free). It is suitable for business personnel to transform requirements into standardized process definitions.

  • Designer Activities :

The function is similar to Activiti Modeler, and it also provides a visual design function based on the BPMN 2.0 specification, but currently it does not fully support the definition of the BPMN specification. It is suitable for developers, and can import the process definition (XML format) designed by business requirement personnel with Signavio into Designer, so that the developer can further process it into a runnable process definition.

  • Activiti Explorer:

Can be used to manage warehouses, users, groups, start processes, task management, etc. This component uses REST style API to provide a basic design model. If the business is simple, it can also be used directly without development. It can also be used as a background administrator's process and task management system.

  • REST Activities :

Provides Restful-style services, allowing clients to interact with the engine's REST API in JSON mode. The universal protocol has cross-platform and cross-language features.

Workflow concept

工作流(Workflow), Is "the automation of part or the whole of the business process in the computer application environment", it mainly solves the problem of "automatically the process of transferring documents, information or tasks among multiple participants in accordance with certain predefined rules. In order to achieve a certain expected business goal, or to promote the realization of this goal".

工作流管理系统(Workflow Management System, WfMS)It is a software system that completes the definition and management of the workload, and executes workflow instances in accordance with the pre-defined workflow rules in the system. Workflow management system is not the business system of the enterprise, but provides a software support environment for the operation of the business system of the enterprise.

工作流管理联盟(WfMC,Workflow Management Coalition)The definition of workflow management system given is: workflow management system is a software system that supports a batch of specially set business processes by executing calculated process definitions. Workflow management systems are used to define, manage, and execute workflows.

工作流管理系统的目标: Manage the work process to ensure that the work is performed by the expected personnel at the right time-insert manual execution and intervention in the automated business process.

Activiti5 is a business process management (BPM) framework released by Alfresco software on May 17, 2010. It is an open source, flexible, and easily extensible executable that covers the fields of business process management, workflow, and service collaboration. Process language framework. Activiti is based on the Apache-licensed open source BPM platform. The founder Tom Baeyens is the project architect of JBoss jBPM. It features an eclipse plug-in, through which developers can draw business directly.

Workflow engine

ProcessEngine object, which is the core of Activiti's work. Responsible for generating various instances and data when the process is running, monitoring and managing the operation of the process.
BPMN: Business Process Model and Notation (BPMN), describes the basic symbols of the process, including how these graphic elements are combined into a business process diagram (Business Process Diagram)

data sheet

Insert picture description here

Table name Table meaning
act_evt_log Event processing log table
act_ge_bytearray General process definition and process resources
act_ge_property System related attributes
Table name Table meaning
act_hi_actinst Historical process examples
act_hi_attachment Historical process attachment
act_hi_comment Historical descriptive information
act_hi_detail Detailed information in historical process operation
act_hi_identitylink User relationship during historical process operation
act_hi_procinst Historical process examples
act_hi_taskinst Historical mission examples
act_hi_varinst Variable information in historical process operation
Table name Table meaning
act_id_group Identity Information-Group Information
act_id_info Identity Information-Group Information
act_id_membership Identity Information-Intermediate Table of User and Group Relationship
act_id_user Identity Information-User Information
Table name Table meaning
act_procdef_info Dead letter mission
Table name Table meaning
act_re_deployment Deployment unit information
act_re_model Model information
act_re_procdef Deployed process definition
Table name Table meaning
act_ru_deadletter_job Execution failed task list
act_ru_event_subscr Runtime events
act_ru_execution Runtime process execution example
act_ru_identitylink User relationship information at runtime
act_ru_job Runtime job
act_ru_suspended_job Pause task while running
act_ru_task Runtime task
act_ru_timer_job Runtime scheduled tasks
act_ru_variable Runtime variable table
Process concepts and terminology
  • (1) A business process represented by a ProcessDefinition. It is used to define the structure and behavior of different steps in the process.
  • (2) Deploying the process definition means loading the process definition into the Activiti database.
  • (3) Process definitions are mainly defined by the BPMN 2.0 standard, and they can also be defined using Java code, and all the defined terms can also be used as Java classes.
  • (4) Once we start to run the process definition, it can be called a process process.
  • (5) processInstance is an execution instance of ProcessDefinition.
  • (6) A StartEvent is related to each business process. It represents the entry point of the process. Similarly, there is an EndEvent that represents the end of the process. We can define the conditions of these events.
  • (7) 开始和结束之间的所有步骤(或元素)称为任务Tasks can be of various types. The most commonly used tasks areUserTasks和ServiceTasks。

UserTasksIt needs to be executed manually by the user. On the other hand, ServiceTasks is configured with a piece of code, and the code will be executed whenever the execution reaches this piece of code.
SequenceFlowsUsed to connect tasks, we can define a SequenceFlows by connecting the source element and the target element; similarly, we can also define conditions on the SequenceFlow to create a conditional path in the process.

Services provided by Activiti

  • RepositoryService helps us implement the deployment of process definitions. This service handles static data related to the process definition.
  • RuntimeService manages ProcessInstances (currently running processes) and process variables
  • TaskService会跟踪 UserTasks,需要由用户手动执行的任务是Activiti API的核心。我们可以使用此服务创建任务,声明并完成任务,分配任务的受让人等。
  • FormService是一项可选服务,它用于定义中开始表单和任务表单。
  • IdentityService管理用户和组。
  • HistoryService会跟踪Activiti Engine的历史记录。我们还可以设置不同的历史级别。
  • ManagementService与元数据相关,在创建应用程序时通常不需要。
  • DynamicBpmnService帮助我们在不重新部署的情况下更改流程中的任何内容。

核心API

ProcessEngine

说明:

    1. 在Activiti中最核心的类,其他的类都是由他而来。
    1. 产生方式:
    1. 可以产生RepositoryService
    1. 可以产生RuntimeService
    1. 可以产生TaskService

各个Service的作用:

  • ·RepositoryService ·管理流程定义

    • 是Activiti的仓库服务类。所谓的仓库指流程定义文档的两个文件:bpmn文件和流程图片。
    • 产生方式:可以产生DeploymentBuilder,用来定义流程部署的相关参数
    • 删除流程定义
  • RuntimeService· 执行管理,包括启动、推进、删除流程实例等操作

    • 是activiti的流程执行服务类。可以从这个服务类中获取很多关于流程执行相关的信息。
  • ·TaskService·任务管理

    • 是activiti的任务服务类。可以从这个类中获取任务的信息。
  • ·HistoryService· 历史管理(执行完的数据的管理)

    • 是activiti的查询历史信息的类。在一个流程执行完成后,这个对象为我们提供查询历史信息。
  • IdentityService ·组织机构管理

  • ·FormService· 一个可选服务,任务表单管理

  • ManagerService

  • ProcessDefinition : 流程定义类。可以从这里获得资源文件等。

  • ProcessInstance :代表流程定义的执行实例。请了一天的假,她就必须发出一个流程实例的申请。一个流程实例包括了所有的运行节点。我们可以利用这个对象来了解当前流程实例的进度等信息。流程实例就表示一个流程从开始到结束的最大的流程分支,即一个流程中流程实例只有一个。

  • Execution:Activiti uses this object to describe each node of the process execution. In the absence of concurrency, Execution is the same as ProcessInstance. The process in which the process is executed once according to the rules defined by the process can represent the execution object Execution.

  • Insert picture description here

  • This example has a feature: wire money (remittance of money) and archive (archive) are executed concurrently. At this time, the main circuit represents ProcessInstance, and each activity in the sub-circuit represents Execution.

总结

*一个流程中,执行对象可以存在多个,但是流程实例只能有一个

  • 当流程按照规则只执行一次的时候,那么流程实例就是执行对象

HelloWorld program (simulation process execution)

Deployment process example:
[External link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-VZCRFoip-1599480491534)(imgclip_2.png "imgclip_2.png")]

Use the RepositoryService deployment process definition, addClasspathResource means to load resource files from the classpath, only one file can be loaded at a time.


Start the process
[External link image transfer failed. The source site may have an anti-leech link mechanism. It is recommended to save the image and upload it directly (img-vDpfm1By-1599480491535)(imgclip_3.png "imgclip_3.png")]

Here we use RuntimeService to start the process instance,


View my personal tasks.
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-uMe64P6a-1599480491535)(imgclip_4.png "imgclip_4.png")]

Here is the query to complete the task using TaskService
**Complete my personal task**
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-mWwH77ZY-1599480491536)(imgclip_5.png "imgclip_5.png")]

Here use TaskService to complete the task handling

Guess you like

Origin blog.csdn.net/sanhewuyang/article/details/108410403