Flowable—基本概念和重要名词解释

Flowable的使用教程

Flowable的用户使用手册

Flowable相关的中文官方项目

Flowable工作流引擎的源代码

Flowable API中的名词详解

 其实根据我最近研究流程引擎这一块,无论是JBPM,还是这个Flowable, 我发现里面有很多名词看着很简单,但是含义都很相近,容易让人混淆,
 在流程引擎中有很多的名词和概念是需要我们提前了解的,有一些是和流程定义标准有关的,有一些是和流程引擎有关的,
包括一些API会涉及到相关的概念,这里就不做具体的分别了,直接对涉及到的名词进行解释,不明白的可以再下面进行评论:

根据无图言屌的理论,我们结合着例子讲:
图是流程图
在这里插入图片描述
Xml文档是流程图对应的文件:gateway.bpmn20.xml

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:flowable="http://flowable.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.flowable.org/processdef">
  <process id="gateway" name="firstdemo" isExecutable="true">
    <dataObject id="tag" name="Agree" itemSubjectRef="xsd:boolean">
      <extensionElements>
        <flowable:value>true</flowable:value>
      </extensionElements>
    </dataObject>
    <startEvent id="startEvent1" flowable:formFieldValidation="true"></startEvent>
    <endEvent id="sid-CFA37A02-2550-4786-B011-66EAAF4FDACD"></endEvent>
    <userTask id="sid-18AB5E62-1C9E-489A-97A8-6C2E55A7BD0C" name="task1" flowable:formFieldValidation="true">
      <documentation>task1</documentation>
      <extensionElements>
        <flowable:executionListener event="start" class="com.example.flowable.CommonExecutionListener"></flowable:executionListener>
        <flowable:taskListener event="create" class="com.example.flowable.CommonTaskListener"></flowable:taskListener>
      </extensionElements>
    </userTask>
    <sequenceFlow id="sid-D6BA2C14-AF21-483A-86CD-62FB46749709" sourceRef="startEvent1" targetRef="sid-18AB5E62-1C9E-489A-97A8-6C2E55A7BD0C"></sequenceFlow>
    <userTask id="sid-F196283E-CC9A-4BBA-9B91-B9E59D52D96D" name="task2" flowable:formFieldValidation="true">
      <documentation>task2</documentation>
    </userTask>
    <sequenceFlow id="sid-3A682C50-C566-49C5-9C9E-9F12E14328FB" sourceRef="sid-18AB5E62-1C9E-489A-97A8-6C2E55A7BD0C" targetRef="sid-F196283E-CC9A-4BBA-9B91-B9E59D52D96D"></sequenceFlow>
    <userTask id="sid-BBCDB2E1-6419-43D2-8532-8D3FC28E49DA" name="task3" flowable:formFieldValidation="true">
      <documentation>task3</documentation>
    </userTask>
    <sequenceFlow id="sid-BC67636C-EBD6-435A-B9CE-8774F2276498" sourceRef="sid-BBCDB2E1-6419-43D2-8532-8D3FC28E49DA" targetRef="sid-CFA37A02-2550-4786-B011-66EAAF4FDACD"></sequenceFlow>
    <sequenceFlow id="sid-F4DD7025-CDCE-491A-8A4A-C096CBA5E691" sourceRef="sid-F196283E-CC9A-4BBA-9B91-B9E59D52D96D" targetRef="sid-FDBE9C91-7195-4FD5-9CF1-B2DA1794ADC7"></sequenceFlow>
    <parallelGateway id="sid-FDBE9C91-7195-4FD5-9CF1-B2DA1794ADC7"></parallelGateway>
    <sequenceFlow id="sid-ADA36BBE-B044-4329-9A87-3BEA833D6938" sourceRef="sid-FDBE9C91-7195-4FD5-9CF1-B2DA1794ADC7" targetRef="sid-BBCDB2E1-6419-43D2-8532-8D3FC28E49DA"></sequenceFlow>
    <userTask id="sid-053E623B-74BB-46D0-82BB-A14AF439A902" name="task4" flowable:formFieldValidation="true">
      <documentation>task4</documentation>
    </userTask>
    <sequenceFlow id="sid-E37EB023-0A51-4322-BB99-CE980DD5A01E" sourceRef="sid-FDBE9C91-7195-4FD5-9CF1-B2DA1794ADC7" targetRef="sid-053E623B-74BB-46D0-82BB-A14AF439A902"></sequenceFlow>
    <endEvent id="sid-DB2195E9-4557-4EA6-A758-C7D8FE21F0AE"></endEvent>
    <sequenceFlow id="sid-FAD95623-29CE-4EFC-9415-36D2E92FCA9C" sourceRef="sid-053E623B-74BB-46D0-82BB-A14AF439A902" targetRef="sid-DB2195E9-4557-4EA6-A758-C7D8FE21F0AE"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_gateway">
    <bpmndi:BPMNPlane bpmnElement="gateway" id="BPMNPlane_gateway">
      <bpmndi:BPMNShape bpmnElement="startEvent1" id="BPMNShape_startEvent1">
        <omgdc:Bounds height="30.0" width="30.0" x="15.0" y="167.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-CFA37A02-2550-4786-B011-66EAAF4FDACD" id="BPMNShape_sid-CFA37A02-2550-4786-B011-66EAAF4FDACD">
        <omgdc:Bounds height="28.0" width="28.0" x="1050.0" y="41.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-18AB5E62-1C9E-489A-97A8-6C2E55A7BD0C" id="BPMNShape_sid-18AB5E62-1C9E-489A-97A8-6C2E55A7BD0C">
        <omgdc:Bounds height="88.0" width="178.0" x="180.0" y="138.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-F196283E-CC9A-4BBA-9B91-B9E59D52D96D" id="BPMNShape_sid-F196283E-CC9A-4BBA-9B91-B9E59D52D96D">
        <omgdc:Bounds height="80.0" width="100.0" x="420.0" y="142.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-BBCDB2E1-6419-43D2-8532-8D3FC28E49DA" id="BPMNShape_sid-BBCDB2E1-6419-43D2-8532-8D3FC28E49DA">
        <omgdc:Bounds height="80.0" width="100.0" x="660.0" y="15.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-FDBE9C91-7195-4FD5-9CF1-B2DA1794ADC7" id="BPMNShape_sid-FDBE9C91-7195-4FD5-9CF1-B2DA1794ADC7">
        <omgdc:Bounds height="40.0" width="40.0" x="565.0" y="162.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-053E623B-74BB-46D0-82BB-A14AF439A902" id="BPMNShape_sid-053E623B-74BB-46D0-82BB-A14AF439A902">
        <omgdc:Bounds height="80.0" width="100.0" x="675.0" y="270.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-DB2195E9-4557-4EA6-A758-C7D8FE21F0AE" id="BPMNShape_sid-DB2195E9-4557-4EA6-A758-C7D8FE21F0AE">
        <omgdc:Bounds height="28.0" width="28.0" x="1050.0" y="296.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="sid-F4DD7025-CDCE-491A-8A4A-C096CBA5E691" id="BPMNEdge_sid-F4DD7025-CDCE-491A-8A4A-C096CBA5E691">
        <omgdi:waypoint x="519.949999999998" y="182.21623376623378"></omgdi:waypoint>
        <omgdi:waypoint x="565.4130434782609" y="182.41304347826087"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-BC67636C-EBD6-435A-B9CE-8774F2276498" id="BPMNEdge_sid-BC67636C-EBD6-435A-B9CE-8774F2276498">
        <omgdi:waypoint x="759.9499999999999" y="55.0"></omgdi:waypoint>
        <omgdi:waypoint x="1050.0" y="55.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-3A682C50-C566-49C5-9C9E-9F12E14328FB" id="BPMNEdge_sid-3A682C50-C566-49C5-9C9E-9F12E14328FB">
        <omgdi:waypoint x="357.94999999989125" y="182.0"></omgdi:waypoint>
        <omgdi:waypoint x="419.9999999999576" y="182.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-FAD95623-29CE-4EFC-9415-36D2E92FCA9C" id="BPMNEdge_sid-FAD95623-29CE-4EFC-9415-36D2E92FCA9C">
        <omgdi:waypoint x="774.9499999999999" y="310.0"></omgdi:waypoint>
        <omgdi:waypoint x="1050.0" y="310.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-ADA36BBE-B044-4329-9A87-3BEA833D6938" id="BPMNEdge_sid-ADA36BBE-B044-4329-9A87-3BEA833D6938">
        <omgdi:waypoint x="595.3562499999999" y="172.3809523809524"></omgdi:waypoint>
        <omgdi:waypoint x="670.9411764705883" y="94.95"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-D6BA2C14-AF21-483A-86CD-62FB46749709" id="BPMNEdge_sid-D6BA2C14-AF21-483A-86CD-62FB46749709">
        <omgdi:waypoint x="44.94999967996604" y="182.0"></omgdi:waypoint>
        <omgdi:waypoint x="180.0" y="182.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-E37EB023-0A51-4322-BB99-CE980DD5A01E" id="BPMNEdge_sid-E37EB023-0A51-4322-BB99-CE980DD5A01E">
        <omgdi:waypoint x="595.4006832646949" y="191.54915730337075"></omgdi:waypoint>
        <omgdi:waypoint x="681.2320658565268" y="270.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>
  • Process Definition
    ProcessDefination就类似于一个模板,像java中的类一样,
  • Process Instance
    Process Instance 就是具体的Process Defination对应的流程实例,类似于Java中的实例
  • Activity

JAVA Activity是流程标准规范BPMN2.0里面的规范,流程中的每一个步骤都是一个Activity,也就是说上面的这个流程图中有4个Activity, 其实就是上面的四个task,activity是主要BPMN中的主要节点,再具体一点,我一一列出来:

 <userTask id="sid-18AB5E62-1C9E-489A-97A8-6C2E55A7BD0C" name="task1" flowable:formFieldValidation="true">
   <documentation>task1</documentation>
   <extensionElements>
     <flowable:executionListener event="start" class="com.example.flowable.CommonExecutionListener"></flowable:executionListener>
     <flowable:taskListener event="create" class="com.example.flowable.CommonTaskListener"></flowable:taskListener>
   </extensionElements>
 </userTask>
 <userTask id="sid-F196283E-CC9A-4BBA-9B91-B9E59D52D96D" name="task2" flowable:formFieldValidation="true">
   <documentation>task2</documentation>
 </userTask>
	<userTask id="sid-BBCDB2E1-6419-43D2-8532-8D3FC28E49DA" name="task3" flowable:formFieldValidation="true">
     <documentation>task3</documentation>
   </userTask>
 	<userTask id="sid-053E623B-74BB-46D0-82BB-A14AF439A902" name="task4" flowable:formFieldValidation="true">
      <documentation>task4</documentation>
    </userTask>
  • Execution
这个是个比较解释的名词,Execution的含义是流程的执行线路,为什么这么说呢?
因为通过Execution可以获得当前ProcessInstance当前执行到那个Activity了,
ProcessInstance接口也实现了Execution接口,

流程进行到task1的时候
这里说一下打印台打印的内容:我是通过运行时环境里面拿到实时的Execution,打印方式是:第一行打印executionList里面execution的个数,然后后面遍历这些Execution,每个作为一行打印 开头均以"execution = "开始.

此时的Execution打印:

init   executionListlist.size() = 2
init   execution = ProcessInstance[cab66306-10ef-11ea-ac73-1c872c5f4209]
init   execution = Execution[ id 'cab6b128-10ef-11ea-ac73-1c872c5f4209' ] - activity 'sid-18AB5E62-1C9E-489A-97A8-6C2E55A7BD0C' 
- parent 'cab66306-10ef-11ea-ac73-1c872c5f4209'
我们可以看到当执行到task1的时候execution有两个,一个Execution是Processinstance 另外一个Execution他的parent是processinstance 
(根据Id确定的)然后我们可以从第二个Execution的属性里面看到 activity对应的节点的Id,
我们对照上面的xml文档里面的内容刚好对应的就是task节点的id

下面我们再看一下complete task1后的:

流程进行到task2的时候

task1   executionListlist.size() = 2
task1   execution = ProcessInstance[cab66306-10ef-11ea-ac73-1c872c5f4209]
task1   execution = Execution[ id 'cab6b128-10ef-11ea-ac73-1c872c5f4209' ] - activity 'sid-F196283E-CC9A-4BBA-9B91-B9E59D52D96D' 
- parent 'cab66306-10ef-11ea-ac73-1c872c5f4209'
按照上面task1的时候的分析

下面我们在看下complete task2后的:

task2   executionListlist.size() = 3
task2   execution = Execution[ id '9ee4f862-10f1-11ea-9a3d-1c872c5f4209' ] - activity 'sid-053E623B-74BB-46D0-82BB-A14AF439A902' 
- parent 'cab66306-10ef-11ea-ac73-1c872c5f4209'
task2   execution = ProcessInstance[cab66306-10ef-11ea-ac73-1c872c5f4209]
task2   execution = Execution[ id 'cab6b128-10ef-11ea-ac73-1c872c5f4209' ] - activity 'sid-BBCDB2E1-6419-43D2-8532-8D3FC28E49DA' 
- parent 'cab66306-10ef-11ea-ac73-1c872c5f4209'
我们现在看下这里有三个execution,除了processInstance之外还有两个Execution,而这两个execution的activity对应的 
分别是Task3和Task4节点的id,为什么会这样呢?因为我们的task2后面是个平行网关,也就是说我们执行Complete task2以后,
task3和task4都可以执行,相当于两条执行路径,所以有两个对应的execution。
  • assignee和owner
这个是针对usertask类型的activity的,一个task我们既可以给他设定assignee也可以设定owner,assignee的含义就是这个task是由谁负责的,
owner是assignee可以指定的那个人,比如一个task的assignee是jack 然后他不想执行可以为这个task设置一个owner,比如是rose,
那这个任务就可以由rose执行
综上我们可以明白execution的意义了,这也是为什么我们说execution是执行路径。
  • 4
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值