Activiti 6.x【11】IntermediateEvent

简介: 版权声明:转载注明出处就OK的说,有些东西会转载,都会注明的说= =如果有冒犯麻烦见谅 https://blog.csdn.net/Pan1458689676/article/details/82728835 ...
版权声明:转载注明出处就OK的说,有些东西会转载,都会注明的说= =如果有冒犯麻烦见谅 https://blog.csdn.net/Pan1458689676/article/details/82728835

IntermediateEvent组件


IntermediateEvent分为抛出事件与捕获事件。基本与边界事件用法类似。依然以信号,消息,错误,时间为载体。具体分为六种。功能的话基本上直接翻译就大致明白。

这里写图片描述

官网上也没有详细的描述,这里主要以两个demo做讲解。
这里写图片描述

Demo1【Timer+Signal+Message】

  • 并行网关前三行为测试信号抛出中间事件与信号捕获中间事件。

ServiceTask绑定如下【两个都绑定了如下委托执行类】
这里写图片描述

ServiceTask

public class ServiceTask implements JavaDelegate {
    @Override
    public void execute(DelegateExecution execution) {
        System.out.println("ServiceTask");
    }
}
  • 并行网关第四行为测试消息捕获中间事件。

ServiceTask绑定如下

这里写图片描述

ServiceTask

public class Message implements JavaDelegate {
    @Override
    public void execute(DelegateExecution execution) {
        System.out.println("Message");
    }
}
  • 并行网关之后为测试事件捕获中间事件。

ServiceTask绑定如下

这里写图片描述

ServiceTask

public class Over implements JavaDelegate {
    @Override
    public void execute(DelegateExecution execution) {
        System.out.println("Over");
    }
}

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="signalmsg" name="signalmsg"></signal>
  <message id="msg" name="msgName"></message>
  <process id="intermediate" name="My process" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <parallelGateway id="parallelgateway1" name="Parallel Gateway"></parallelGateway>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="parallelgateway1"></sequenceFlow>
    <intermediateThrowEvent id="signalintermediatethrowevent1" name="SignalThrowEvent">
      <signalEventDefinition signalRef="signalmsg"></signalEventDefinition>
    </intermediateThrowEvent>
    <intermediateCatchEvent id="signalintermediatecatchevent1" name="SignalCatchEvent">
      <signalEventDefinition signalRef="signalmsg"></signalEventDefinition>
    </intermediateCatchEvent>
    <intermediateCatchEvent id="signalintermediatecatchevent2" name="SignalCatchEvent">
      <signalEventDefinition signalRef="signalmsg"></signalEventDefinition>
    </intermediateCatchEvent>
    <sequenceFlow id="flow2" sourceRef="parallelgateway1" targetRef="signalintermediatecatchevent1"></sequenceFlow>
    <sequenceFlow id="flow3" sourceRef="parallelgateway1" targetRef="signalintermediatecatchevent2"></sequenceFlow>
    <serviceTask id="servicetask1" name="Service Task" activiti:class="com.ptm.prdemo.servicetask.ServiceTask"></serviceTask>
    <sequenceFlow id="flow4" sourceRef="signalintermediatecatchevent1" targetRef="servicetask1"></sequenceFlow>
    <serviceTask id="servicetask2" name="Service Task" activiti:class="com.ptm.prdemo.servicetask.ServiceTask"></serviceTask>
    <sequenceFlow id="flow5" sourceRef="signalintermediatecatchevent2" targetRef="servicetask2"></sequenceFlow>
    <userTask id="usertask1" name="User Task"></userTask>
    <sequenceFlow id="flow6" sourceRef="parallelgateway1" targetRef="usertask1"></sequenceFlow>
    <sequenceFlow id="flow7" sourceRef="usertask1" targetRef="signalintermediatethrowevent1"></sequenceFlow>
    <parallelGateway id="parallelgateway2" name="Parallel Gateway"></parallelGateway>
    <sequenceFlow id="flow8" sourceRef="signalintermediatethrowevent1" targetRef="parallelgateway2"></sequenceFlow>
    <sequenceFlow id="flow9" sourceRef="servicetask1" targetRef="parallelgateway2"></sequenceFlow>
    <sequenceFlow id="flow10" sourceRef="servicetask2" targetRef="parallelgateway2"></sequenceFlow>
    <intermediateCatchEvent id="messageintermediatecatchevent1" name="MessageCatchEvent">
      <messageEventDefinition messageRef="msg"></messageEventDefinition>
    </intermediateCatchEvent>
    <sequenceFlow id="flow12" sourceRef="parallelgateway1" targetRef="messageintermediatecatchevent1"></sequenceFlow>
    <serviceTask id="servicetask3" name="Service Task" activiti:class="com.ptm.prdemo.servicetask.Message"></serviceTask>
    <sequenceFlow id="flow13" sourceRef="messageintermediatecatchevent1" targetRef="servicetask3"></sequenceFlow>
    <sequenceFlow id="flow14" sourceRef="servicetask3" targetRef="parallelgateway2"></sequenceFlow>
    <intermediateCatchEvent id="timerintermediatecatchevent1" name="TimerCatchEvent">
      <timerEventDefinition>
        <timeDuration>R1/PT5S</timeDuration>
      </timerEventDefinition>
    </intermediateCatchEvent>
    <sequenceFlow id="flow15" sourceRef="parallelgateway2" targetRef="timerintermediatecatchevent1"></sequenceFlow>
    <serviceTask id="servicetask4" name="Service Task" activiti:class="com.ptm.prdemo.servicetask.Over"></serviceTask>
    <sequenceFlow id="flow16" sourceRef="timerintermediatecatchevent1" targetRef="servicetask4"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow17" sourceRef="servicetask4" targetRef="endevent1"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_intermediate">
    <bpmndi:BPMNPlane bpmnElement="intermediate" id="BPMNPlane_intermediate">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="120.0" y="200.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="parallelgateway1" id="BPMNShape_parallelgateway1">
        <omgdc:Bounds height="40.0" width="40.0" x="230.0" y="197.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="signalintermediatethrowevent1" id="BPMNShape_signalintermediatethrowevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="585.0" y="90.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="signalintermediatecatchevent1" id="BPMNShape_signalintermediatecatchevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="410.0" y="200.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="signalintermediatecatchevent2" id="BPMNShape_signalintermediatecatchevent2">
        <omgdc:Bounds height="35.0" width="35.0" x="410.0" y="310.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask1" id="BPMNShape_servicetask1">
        <omgdc:Bounds height="55.0" width="105.0" x="550.0" y="190.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask2" id="BPMNShape_servicetask2">
        <omgdc:Bounds height="55.0" width="105.0" x="550.0" y="300.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
        <omgdc:Bounds height="55.0" width="105.0" x="375.0" y="80.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="parallelgateway2" id="BPMNShape_parallelgateway2">
        <omgdc:Bounds height="40.0" width="40.0" x="770.0" y="197.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="messageintermediatecatchevent1" id="BPMNShape_messageintermediatecatchevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="410.0" y="390.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask3" id="BPMNShape_servicetask3">
        <omgdc:Bounds height="55.0" width="105.0" x="550.0" y="380.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="timerintermediatecatchevent1" id="BPMNShape_timerintermediatecatchevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="880.0" y="200.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask4" id="BPMNShape_servicetask4">
        <omgdc:Bounds height="55.0" width="105.0" x="960.0" y="190.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="1140.0" y="200.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="155.0" y="217.0"></omgdi:waypoint>
        <omgdi:waypoint x="230.0" y="217.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="270.0" y="217.0"></omgdi:waypoint>
        <omgdi:waypoint x="410.0" y="217.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="250.0" y="237.0"></omgdi:waypoint>
        <omgdi:waypoint x="250.0" y="327.0"></omgdi:waypoint>
        <omgdi:waypoint x="410.0" y="327.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
        <omgdi:waypoint x="445.0" y="217.0"></omgdi:waypoint>
        <omgdi:waypoint x="550.0" y="217.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
        <omgdi:waypoint x="445.0" y="327.0"></omgdi:waypoint>
        <omgdi:waypoint x="550.0" y="327.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
        <omgdi:waypoint x="250.0" y="197.0"></omgdi:waypoint>
        <omgdi:waypoint x="250.0" y="107.0"></omgdi:waypoint>
        <omgdi:waypoint x="375.0" y="107.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
        <omgdi:waypoint x="480.0" y="107.0"></omgdi:waypoint>
        <omgdi:waypoint x="585.0" y="107.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8">
        <omgdi:waypoint x="620.0" y="107.0"></omgdi:waypoint>
        <omgdi:waypoint x="790.0" y="107.0"></omgdi:waypoint>
        <omgdi:waypoint x="790.0" y="197.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow9" id="BPMNEdge_flow9">
        <omgdi:waypoint x="655.0" y="217.0"></omgdi:waypoint>
        <omgdi:waypoint x="770.0" y="217.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow10" id="BPMNEdge_flow10">
        <omgdi:waypoint x="655.0" y="327.0"></omgdi:waypoint>
        <omgdi:waypoint x="790.0" y="327.0"></omgdi:waypoint>
        <omgdi:waypoint x="790.0" y="237.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow12" id="BPMNEdge_flow12">
        <omgdi:waypoint x="250.0" y="237.0"></omgdi:waypoint>
        <omgdi:waypoint x="250.0" y="407.0"></omgdi:waypoint>
        <omgdi:waypoint x="410.0" y="407.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow13" id="BPMNEdge_flow13">
        <omgdi:waypoint x="445.0" y="407.0"></omgdi:waypoint>
        <omgdi:waypoint x="550.0" y="407.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow14" id="BPMNEdge_flow14">
        <omgdi:waypoint x="655.0" y="407.0"></omgdi:waypoint>
        <omgdi:waypoint x="790.0" y="407.0"></omgdi:waypoint>
        <omgdi:waypoint x="790.0" y="237.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow15" id="BPMNEdge_flow15">
        <omgdi:waypoint x="810.0" y="217.0"></omgdi:waypoint>
        <omgdi:waypoint x="880.0" y="217.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow16" id="BPMNEdge_flow16">
        <omgdi:waypoint x="915.0" y="217.0"></omgdi:waypoint>
        <omgdi:waypoint x="960.0" y="217.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow17" id="BPMNEdge_flow17">
        <omgdi:waypoint x="1065.0" y="217.0"></omgdi:waypoint>
        <omgdi:waypoint x="1140.0" y="217.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

测试代码

@Test
public void Intermediate() throws InterruptedException{
    Deployment deployment = repositoryService.createDeployment()
                    .name("intermediate")
                    .addClasspathResource("bpmn/intermediate.bpmn")
                    .addClasspathResource("bpmn/intermediate.png")
                    .deploy();
    System.out.println("部署ID:"+deployment.getId());
    System.out.println("部署名称:"+deployment.getName());
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("intermediate");

    Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
    System.out.println("当前流程任务:" + task.getName());
    taskService.complete(task.getId());

    //发送message事件
    Execution ex = runtimeService.createExecutionQuery()
            .processDefinitionId(pi.getProcessDefinitionId())
            .activityId("messageintermediatecatchevent1")
            .singleResult();
    runtimeService.messageEventReceived("msgName", ex.getId());
    Thread.sleep(1000 *15);
}

这里写图片描述

Demo2【Compensation+None】

流程图总览

这里写图片描述

NoneThrowingEvent绑定

该事件通常用于指示流程中实现的某些状态。一般用于做监听。
这里写图片描述

ListenTest

public class ListenTest implements ExecutionListener {
    @Override
    public void notify(DelegateExecution execution) {
        System.out.println("执行监听");
    }
}

ServiceTask绑定
这里写图片描述

ServiceTask

public class ServiceTask implements JavaDelegate {
    @Override
    public void execute(DelegateExecution execution) {
        System.out.println("ServiceTask");
    }
}

ServiceTask2

public class ServiceTask2 implements JavaDelegate {
    @Override
    public void execute(DelegateExecution execution) {
        System.out.println("ServiceTask2");
    }
}

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">
  <process id="Middle" name="My process" isExecutable="true">
    <intermediateThrowEvent id="compensationintermediatethrowevent1" name="CompensationThrowingEvent">
      <compensateEventDefinition></compensateEventDefinition>
    </intermediateThrowEvent>
    <intermediateThrowEvent id="noneintermediatethrowevent1" name="NoneThrowEvent">
      <extensionElements>
        <activiti:executionListener event="start" class="com.ptm.prdemo.servicetask.ListenTest"></activiti:executionListener>
      </extensionElements>
    </intermediateThrowEvent>
    <startEvent id="startevent1" name="Start"></startEvent>
    <serviceTask id="servicetask2" name="Service Task" activiti:class="com.ptm.prdemo.servicetask.ServiceTask2"></serviceTask>
    <serviceTask id="servicetask3" name="Service Task" activiti:class="com.ptm.prdemo.servicetask.ServiceTask"></serviceTask>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="servicetask3"></sequenceFlow>
    <sequenceFlow id="flow2" sourceRef="servicetask3" targetRef="servicetask2"></sequenceFlow>
    <sequenceFlow id="flow3" sourceRef="servicetask2" targetRef="noneintermediatethrowevent1"></sequenceFlow>
    <sequenceFlow id="flow4" sourceRef="noneintermediatethrowevent1" targetRef="compensationintermediatethrowevent1"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow6" sourceRef="compensationintermediatethrowevent1" targetRef="endevent1"></sequenceFlow>
    <serviceTask id="servicetask4" name="Service Task" isForCompensation="true" activiti:class="com.ptm.prdemo.servicetask.ServiceTask"></serviceTask>
    <serviceTask id="servicetask5" name="Service Task" isForCompensation="true" activiti:class="com.ptm.prdemo.servicetask.ServiceTask2"></serviceTask>
    <boundaryEvent id="boundarycompensation1" name="Compensate" attachedToRef="servicetask3" cancelActivity="true">
      <compensateEventDefinition></compensateEventDefinition>
    </boundaryEvent>
    <boundaryEvent id="boundarycompensation2" name="Compensate" attachedToRef="servicetask2" cancelActivity="true">
      <compensateEventDefinition></compensateEventDefinition>
    </boundaryEvent>
    <association id="association1" sourceRef="boundarycompensation1" targetRef="servicetask4"></association>
    <association id="association2" sourceRef="boundarycompensation2" targetRef="servicetask5"></association>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_Middle">
    <bpmndi:BPMNPlane bpmnElement="Middle" id="BPMNPlane_Middle">
      <bpmndi:BPMNShape bpmnElement="compensationintermediatethrowevent1" id="BPMNShape_compensationintermediatethrowevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="530.0" y="200.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="noneintermediatethrowevent1" id="BPMNShape_noneintermediatethrowevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="440.0" y="200.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="60.0" y="200.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask2" id="BPMNShape_servicetask2">
        <omgdc:Bounds height="55.0" width="105.0" x="280.0" y="190.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="boundarycompensation2" id="BPMNShape_boundarycompensation2">
        <omgdc:Bounds height="30.0" width="30.0" x="350.0" y="230.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask3" id="BPMNShape_servicetask3">
        <omgdc:Bounds height="55.0" width="105.0" x="130.0" y="190.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="boundarycompensation1" id="BPMNShape_boundarycompensation1">
        <omgdc:Bounds height="30.0" width="30.0" x="190.0" y="230.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="650.0" y="200.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask4" id="BPMNShape_servicetask4">
        <omgdc:Bounds height="55.0" width="105.0" x="200.0" y="290.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask5" id="BPMNShape_servicetask5">
        <omgdc:Bounds height="55.0" width="105.0" x="400.0" y="290.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="95.0" y="217.0"></omgdi:waypoint>
        <omgdi:waypoint x="130.0" y="217.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="235.0" y="217.0"></omgdi:waypoint>
        <omgdi:waypoint x="280.0" y="217.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="385.0" y="217.0"></omgdi:waypoint>
        <omgdi:waypoint x="440.0" y="217.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
        <omgdi:waypoint x="475.0" y="217.0"></omgdi:waypoint>
        <omgdi:waypoint x="530.0" y="217.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
        <omgdi:waypoint x="565.0" y="217.0"></omgdi:waypoint>
        <omgdi:waypoint x="650.0" y="217.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="association1" id="BPMNEdge_association1">
        <omgdi:waypoint x="205.0" y="260.0"></omgdi:waypoint>
        <omgdi:waypoint x="252.0" y="290.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="association2" id="BPMNEdge_association2">
        <omgdi:waypoint x="365.0" y="260.0"></omgdi:waypoint>
        <omgdi:waypoint x="452.0" y="290.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

测试代码

@Test
public void Middle() throws InterruptedException{
    Deployment deployment = repositoryService.createDeployment()
                    .name("Middle")
                    .addClasspathResource("bpmn/Middle.bpmn")
                    .addClasspathResource("bpmn/Middle.png")
                    .deploy();
    System.out.println("部署ID:"+deployment.getId());
    System.out.println("部署名称:"+deployment.getName());
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("Middle");
}

这里写图片描述

CompensationThrowingEvent注意事项【详细可以参考官网】

CompensationThrowingEvent可用于触发补偿。

如果在包含子流程的范围内抛出补偿且子流程包含具有补偿处理程序的活动,则补偿仅在抛出补偿时成功完成后才传播到子流程。如果嵌套在子流程中的某些活动已完成并附加了补偿处理程序,则如果尚未完成包含这些活动的子流程,则不会执行补偿处理程序。

目录
相关文章
|
6月前
|
XML 数据可视化 安全
一文了解Activiti7
一文了解Activiti7
132 0
|
6月前
|
XML Java API
Activiti应用
Activiti应用
90 0
|
数据可视化 Java 关系型数据库
01-认识Activiti
类似如请假、离职、出差、报销这种有审批流程的业务,我们都可以称之为工作流(也叫流程引擎),它可以帮助用户实现一个审批流程的可视化,借助于工作流引擎可以搭建客户关系管理系统(CRM)、运输管理系统(TMS)、仓储管理系统(WMS)、财务费用系统等多种复杂业务系统。
103 0
|
安全 Java 测试技术
Activiti-Activiti整合篇
Activiti-Activiti整合篇
Activiti-Activiti整合篇
|
架构师 应用服务中间件 Apache
Activiti就是这么简单(二)
Activiti5是由Alfresco软件在2010年5月17日发布的业务流程管理(BPM)框架,它是覆盖了业务流程管理、工作流、服务协作等领域的一个开源的、灵活的、易扩展的可执行流程语言框架。Activiti基于Apache许可的开源BPM平台,创始人Tom Baeyens是JBoss jBPM的项目架构师,它特色是提供了eclipse插件,开发人员可以通过插件直接绘画出业务 流程图。.
212 0
Activiti就是这么简单(二)
|
架构师 应用服务中间件 API
Activiti就是这么简单(四)
Activiti5是由Alfresco软件在2010年5月17日发布的业务流程管理(BPM)框架,它是覆盖了业务流程管理、工作流、服务协作等领域的一个开源的、灵活的、易扩展的可执行流程语言框架。Activiti基于Apache许可的开源BPM平台,创始人Tom Baeyens是JBoss jBPM的项目架构师,它特色是提供了eclipse插件,开发人员可以通过插件直接绘画出业务 流程图。.
226 0
Activiti就是这么简单(四)
|
架构师 应用服务中间件 Apache
Activiti就是这么简单(三)
Activiti5是由Alfresco软件在2010年5月17日发布的业务流程管理(BPM)框架,它是覆盖了业务流程管理、工作流、服务协作等领域的一个开源的、灵活的、易扩展的可执行流程语言框架。Activiti基于Apache许可的开源BPM平台,创始人Tom Baeyens是JBoss jBPM的项目架构师,它特色是提供了eclipse插件,开发人员可以通过插件直接绘画出业务 流程图。.
287 0
Activiti就是这么简单(三)
|
架构师 Java 应用服务中间件
Activiti就是这么简单(一)
Activiti5是由Alfresco软件在2010年5月17日发布的业务流程管理(BPM)框架,它是覆盖了业务流程管理、工作流、服务协作等领域的一个开源的、灵活的、易扩展的可执行流程语言框架。Activiti基于Apache许可的开源BPM平台,创始人Tom Baeyens是JBoss jBPM的项目架构师,它特色是提供了eclipse插件,开发人员可以通过插件直接绘画出业务 流程图。.
385 0
Activiti就是这么简单(一)
|
XML 数据格式
Activiti 6.x【10】BoundaryEvent【下】
版权声明:转载注明出处就OK的说,有些东西会转载,都会注明的说= =如果有冒犯麻烦见谅 https://blog.csdn.net/Pan1458689676/article/details/82720556 ...
2509 0
|
XML 数据格式
Activiti 6.x【9】BoundaryEvent【上】
版权声明:转载注明出处就OK的说,有些东西会转载,都会注明的说= =如果有冒犯麻烦见谅 https://blog.csdn.net/Pan1458689676/article/details/82717765 ...
2186 0