catalogue
Create activiti.cfg.xml configuration file (fixed name)
Building activit y related data tables
2 general data sheets (act_ge_)
8 process history records (act_hi_)
3 process definition sheets (act_re_)
6 operation instance tables (act_ru_)
Introduction to process symbols
Introduce dependency
Create activiti.cfg.xml configuration file (fixed name)
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <!-- this bean of id It cannot be changed--> <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration"> <property name="jdbcDriver" value="com.mysql.cj.jdbc.Driver"/> <property name="jdbcUrl" value="jdbc:mysql://101.35.118.177:3306/study-activiti"/> <property name="jdbcUsername" value="root"/> <property name="jdbcPassword" value="Citi@2014"/> <!-- activiti When the database is generated ture If there is a response table in the database, it is used directly without regeneration --> <property name="databaseSchemaUpdate" value="true"/> </bean> </beans>
Building activit y related data tables
Mode 1:
package com.any.utils; import org.activiti.engine.ProcessEngine; import org.activiti.engine.ProcessEngines; public class CreateActivitiSchema { /** * Use the default method provided by activiti to create mysql tables * @throws * @update 2021-11-15 15:59 by 15821 */ public static void main(String[] args) { // You need to use the tool class processEngine provided by processEngine and use the method getDefaultProcessEngine()\ // Use the getDefaultProcessEngine method to get the defined information from Activiti.cfg.xml ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); System.out.println(processEngine); } }
Mode 2:
package com.any.utils; import org.activiti.engine.ProcessEngine; import org.activiti.engine.ProcessEngineConfiguration; import org.activiti.engine.ProcessEngines; import org.activiti.engine.RepositoryService; import org.activiti.engine.repository.Deployment; public class CreateActivitiSchema { /** * Create data tables based on custom xml and bean names * @throws * @update 2021-11-15 15:59 by 15821 */ public static void main(String[] args) { ProcessEngineConfiguration configuration = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource( "activiti.cfg.xml","processEngineConfiguration"); ProcessEngine processEngine = configuration.buildProcessEngine(); System.out.println(processEngine); } }
Table structure
2 general data sheets (act_ge_)
Table name | describe | |
ACT_GE_BYTEARRAY | Common process definitions and process resources | |
ACT_GE_PROPERTY | System related properties |
8 process history records (act_hi_)
Table name | describe |
ACT_HI_ACTINST | Historical process instances |
ACT_HI_ATTACHMENT | Historical process attachments |
ACT_HI_COMMENT | Description of history |
ACT_HI_DETAIL | Details of historical process operation |
ACT_HI_IDENTITYLINK | User relationship during historical process operation |
ACT_HI_PROCINST | Historical process instances |
ACT_HI_TASKINST | Historical task instances |
ACT_HI_VARINST | Variable information in historical process |
3 process definition sheets (act_re_)
Table name | describe | |
ACT_RE_DEPLOYMENT | Deployment unit information | |
ACT_RE_MODEL | Model information | |
ACT_RE_PROCDEF | Deployed process definitions |
6 operation instance tables (act_ru_)
Table name | describe | |
ACT_RU_DEADLETTER_JOB | ||
ACT_RU_EVENT_SUBSCR | Runtime events | |
ACT_RU_EXECUTION | Runtime process execution instance | |
ACT_RU_IDENTITYLINK | The runtime user relationship information stores the relevant information of task nodes and participants | |
ACT_RU_INTEGRATION | ||
ACT_RU_JOB | Runtime job | |
ACT_RU_SUSPENDED_JOB | ||
ACT_RU_TASK | Runtime tasks | |
ACT_RU_TIMER_JOB | ||
ACT_RU_VARIABLE | Runtime variable table |
Other 2 sheets
Table name | describe | |
ACT_EVT_LOG | Event log | |
ACT_PROCDEF_INFO | Dynamic change information of process definition |
Introduction to process symbols
BPMN 2.0 is an abbreviation for business process modeling notation 2.0
Event event
activity
Activity is a general term for work and task. An activity can be a task or a processing flow of a subtask
Gateway AateWay
Network management is used for decision-making and is a common gateway
Exclusive gateway
- Only one path will be selected. When the process is executed to the gateway, it will be calculated one by one according to the order of the output flow. When the condition calculation result is true, continue to execute the current network
- If multiple routes are executed at the same time and the result is true, the first route with the value of true will be executed. If all routes are not true, the engine will throw an exception
- Exclusive gateways need to be used in combination with conditional order. The default attribute specifies the default order flow. When all conditions are not met, the default order flow will be executed
Parallel gateway (+)
All routes will be selected at the same time
- Split - all output sequential streams are executed in parallel, and a parallel execution line is created for each sequential stream.
- Merge - all routes split and executed from the parallel gateway wait here until all routes are executed
Containment gateway
Multiple lines can be executed at the same time, or conditions can be set on the gateway
- Split - calculate the expression on each route. When the expression evaluates to true, create a parallel route and continue execution
- Merge - all routes split and executed from the parallel gateway wait here until all routes are executed
Event-based Gateway
It is specially set for intermediate capture events, allowing multiple output streams to point to multiple different intermediate capture events.
Flow direction
Flow direction is the connection connecting two process nodes. Common flow directions include the following:
Added later
Workflow engine
ProcessEngine object, which is the core of Activiti's work. Responsible for generating various instances and data during process operation, monitoring and managing process operation.
Service overview
All service s can be obtained through the process engine
Service name | describe | |
RepositoryService | Activiti's resource management class | |
RuntimeService | Activiti's process operation management class | |
TaskService | Task management class of Activiti | |
HistoryService | activiti's history management class | |
ManagerService | activiti's engine management class |
Introductory experiment
deploy
Obtain the RepositoryService through ProcessEngin and deploy the involved table operations (act_ge_byte resource table, ACT_RE_DEPLOYMENT table, ACT_RE_PROCDEF process definition table)
/** * Deployment process * @update 2021-11-16 17:22 by 15821 */ public void testDeployment() { //1. Create processsEngine ProcessEngineConfiguration configuration = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource( "activiti.cfg.xml","processEngineConfiguration"); ProcessEngine processEngine = configuration.buildProcessEngine(); //2. Obtain repositoryService RepositoryService repositoryService = processEngine.getRepositoryService(); //3. Use service for process deployment Deployment deployment = repositoryService.createDeployment() .name("Create travel process") .addClasspathResource("bpmn/evection.bpmn20.xml") .deploy(); System.out.println(deployment.getId()); System.out.println(deployment.getName()); }
start-up
Get the RuntimeService through ProcessEngin and start it according to the key defined by the process
Operation table
- ACT_HI_ACTINST Process instance execution history
- ACT_HI_IDENTITYLINK History information of process participating users
- ACT_HI_PROCINST History information of process instances
- ACT_HI_TASKINST Historical information of process tasks
- ACT_RU_EXECUTION Process execution information
- ACT_RU_IDENTITYLINK Participating user information of the process
- ACT_RU_TASK Process current task xi
/** * Start process * @update 2021-11-16 17:22 by 15821 */ public void testStartProcess(){ //1. Create processsEngine ProcessEngineConfiguration configuration = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource( "activiti.cfg.xml","processEngineConfiguration"); ProcessEngine processEngine = configuration.buildProcessEngine(); RuntimeService runtimeService = processEngine.getRuntimeService(); ProcessInstance myEvection = runtimeService.startProcessInstanceByKey("myEvection"); System.out.println("Process definition ID: "+myEvection.getProcessDefinitionId()); System.out.println("Process instance ID: "+myEvection.getId()); System.out.println("current activity ID: "+myEvection.getActivityId()); }
Task query
Obtain TaskService through ProcessEngin and query according to the key and person in charge name defined by the process
/** * Query personal tasks * @update 2021-11-16 17:56 by 15821 */ public void testFindPersonalTaskList(){ //1. Create processsEngine ProcessEngineConfiguration configuration = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource( "activiti.cfg.xml","processEngineConfiguration"); ProcessEngine processEngine = configuration.buildProcessEngine(); TaskService taskService = processEngine.getTaskService(); List<Task> list = taskService.createTaskQuery() .processDefinitionKey("myEvection") .taskAssignee("rose") .list(); }
Mission accomplished
Obtain the TaskService through ProcessEngin and complete it according to the task id
/** * Complete the current personal task * @update 2021-11-16 18:19 by 15821 */ public void testFinshPersonalTask(){ ProcessEngineConfiguration configuration = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource( "activiti.cfg.xml","processEngineConfiguration"); ProcessEngine processEngine = configuration.buildProcessEngine(); TaskService taskService = processEngine.getTaskService(); taskService.complete("10002"); }