1.声明
当前内容主要为本人学习和使用Activiti6的操作,主要为一个简单的支付订单的例子(简陋版)
其中涉及的内容有:
- 用户任务和服务任务
- 取消边界事件、错误边界事件和定时边界事件
- 平行网关和判断网关
- 取消结束事件
- 信号的catching和throwing事件
2.基本的流程
与此对应的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:activiti="http://activiti.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.activiti.org/test">
<signal id="paySuccess" name="用户支付成功" activiti:scope="processInstance"></signal>
<error id="errorFlag" errorCode="500" ></error>
<process id="TransationSubProcessTest" name="TransationSubProcessTest" isExecutable="true">
<startEvent id="startevent1" name="Start"></startEvent>
<transaction id="transaction1" name="用户支付订单事务">
<startEvent id="startevent2" name="Start"></startEvent>
<userTask id="usertask1" name="用户提交订单"></userTask>
<serviceTask id="servicetask1" name="锁定库存" activiti:class="com.hy.springboot.activiti6.service.ServiceTaskLockStockJavaDelegate"></serviceTask>
<serviceTask id="servicetask2" name="校验支付" activiti:class="com.hy.springboot.activiti6.service.ServiceTaskPayValidateJavaDelegate"></serviceTask>
<boundaryEvent id="boundarycompensation1" name="Compensate" attachedToRef="servicetask1" cancelActivity="true">
<compensateEventDefinition></compensateEventDefinition>
</boundaryEvent>
<serviceTask id="servicetask3" name="取消库存锁定" isForCompensation="true" activiti:class="com.hy.springboot.activiti6.service.ServiceTaskUnLockStockJavaDelegate"></serviceTask>
<boundaryEvent id="boundaryerror1" name="Error" attachedToRef="servicetask2">
<errorEventDefinition errorRef="errorFlag"></errorEventDefinition>
</boundaryEvent>
<sequenceFlow id="flow3" name="to Service Task" sourceRef="usertask1" targetRef="servicetask1"></sequenceFlow>
<sequenceFlow id="flow4" name="to User Task" sourceRef="startevent2" targetRef="usertask1"></sequenceFlow>
<endEvent id="cancelendevent1" name="CancelEnd">
<cancelEventDefinition></cancelEventDefinition>
</endEvent>
<sequenceFlow id="flow7" name="to CancelEnd" sourceRef="boundaryerror1" targetRef="cancelendevent1"></sequenceFlow>
<parallelGateway id="parallelgateway1" name="Parallel Gateway"></parallelGateway>
<sequenceFlow id="flow9" name="to Parallel Gateway" sourceRef="servicetask1" targetRef="parallelgateway1"></sequenceFlow>
<userTask id="usertask2" name="用户支付"></userTask>
<sequenceFlow id="flow10" name="to User Task" sourceRef="parallelgateway1" targetRef="usertask2"></sequenceFlow>
<boundaryEvent id="boundarytimer1" name="Timer" attachedToRef="usertask2" cancelActivity="true">
<timerEventDefinition>
<timeDuration>PT15S</timeDuration>
</timerEventDefinition>
</boundaryEvent>
<endEvent id="cancelendevent2" name="CancelEnd">
<cancelEventDefinition></cancelEventDefinition>
</endEvent>
<sequenceFlow id="flow13" name="to CancelEnd" sourceRef="boundarytimer1" targetRef="cancelendevent2"></sequenceFlow>
<parallelGateway id="parallelgateway2" name="Parallel Gateway"></parallelGateway>
<sequenceFlow id="flow15" name="to Parallel Gateway" sourceRef="servicetask2" targetRef="parallelgateway2"></sequenceFlow>
<endEvent id="endevent4" name="End"></endEvent>
<sequenceFlow id="flow16" name="to End" sourceRef="parallelgateway2" targetRef="endevent4"></sequenceFlow>
<userTask id="usertask3" name="用户取消订单"></userTask>
<sequenceFlow id="flow17" name="to User Task" sourceRef="parallelgateway1" targetRef="usertask3"></sequenceFlow>
<endEvent id="cancelendevent3" name="CancelEnd">
<cancelEventDefinition></cancelEventDefinition>
</endEvent>
<sequenceFlow id="flow20" name="to CancelEnd" sourceRef="usertask3" targetRef="cancelendevent3"></sequenceFlow>
<exclusiveGateway id="exclusivegateway1" name="Exclusive Gateway"></exclusiveGateway>
<sequenceFlow id="flow21" name="to Exclusive Gateway" sourceRef="usertask2" targetRef="exclusivegateway1"></sequenceFlow>
<sequenceFlow id="flow23" name="支付失败" sourceRef="exclusivegateway1" targetRef="usertask2">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${!isPay}]]></conditionExpression>
</sequenceFlow>
<intermediateCatchEvent id="signalintermediatecatchevent1" name="SignalCatchEvent">
<signalEventDefinition signalRef="paySuccess"></signalEventDefinition>
</intermediateCatchEvent>
<sequenceFlow id="flow26" name="to SignalCatchEvent" sourceRef="parallelgateway1" targetRef="signalintermediatecatchevent1"></sequenceFlow>
<sequenceFlow id="flow27" name="to 校验支付" sourceRef="signalintermediatecatchevent1" targetRef