Activiti 错误结束事件和边界错误事件

实例流程图:



当子程序 付款完成时,出现error时,会错误结束事件,重新付款, 下面是我的xml 和  class,xml中,

userTask2    activiti:class为 class 路径

<?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="Transaction" name="Transaction" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <userTask id="usertask1" name="下单" activiti:assignee="${userid}"></userTask>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow3" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
    <subProcess id="subprocess1" name="付款子程序">
      <userTask id="usertask2" name="付款" activiti:assignee="${userid}" activiti:class="com.activiti.SecondTestRunningTask"></userTask>
      <startEvent id="startevent2" name="Start"></startEvent>
      <userTask id="usertask5" name="付款成功" activiti:assignee="${userid}"></userTask>
      <endEvent id="errorendevent1" name="ErrorEnd">
        <errorEventDefinition errorRef="error_99"></errorEventDefinition>
      </endEvent>
      <endEvent id="endevent2" name="End"></endEvent>
      <sequenceFlow id="flow7" sourceRef="usertask5" targetRef="endevent2"></sequenceFlow>
      <sequenceFlow id="flow13" sourceRef="startevent2" targetRef="usertask2"></sequenceFlow>
      <parallelGateway id="parallelgateway1" name="Parallel Gateway"></parallelGateway>
      <sequenceFlow id="flow17" sourceRef="usertask2" targetRef="parallelgateway1"></sequenceFlow>
      <sequenceFlow id="flow18" sourceRef="parallelgateway1" targetRef="usertask5"></sequenceFlow>
      <sequenceFlow id="flow19" sourceRef="parallelgateway1" targetRef="errorendevent1">
        <conditionExpression xsi:type="tFormalExpression"><![CDATA[${haha==1}]]></conditionExpression>
      </sequenceFlow>
    </subProcess>
    <sequenceFlow id="flow4" sourceRef="usertask1" targetRef="subprocess1"></sequenceFlow>
    <userTask id="usertask4" name="收货" activiti:assignee="${userid}"></userTask>
    <userTask id="usertask3" name="发货" activiti:assignee="${userid}"></userTask>
    <boundaryEvent id="boundarytimer2" name="Timer" attachedToRef="usertask1" cancelActivity="true">
      <timerEventDefinition>
        <timeDuration>PT1M</timeDuration>
      </timerEventDefinition>
    </boundaryEvent>
    <boundaryEvent id="boundaryerror1" name="Error" attachedToRef="subprocess1">
      <errorEventDefinition errorRef="error_99"></errorEventDefinition>
    </boundaryEvent>
    <endEvent id="endevent3" name="End"></endEvent>
    <sequenceFlow id="flow8" sourceRef="subprocess1" targetRef="usertask3"></sequenceFlow>
    <sequenceFlow id="flow9" sourceRef="usertask3" targetRef="usertask4"></sequenceFlow>
    <sequenceFlow id="flow10" sourceRef="usertask4" targetRef="endevent3"></sequenceFlow>
    <userTask id="usertask6" name="重新付款" activiti:assignee="${userid}"></userTask>
    <sequenceFlow id="flow11" sourceRef="boundaryerror1" targetRef="usertask6"></sequenceFlow>
    <sequenceFlow id="flow15" name="超时付款" sourceRef="boundarytimer2" targetRef="endevent3"></sequenceFlow>
    <sequenceFlow id="flow16" sourceRef="usertask6" targetRef="subprocess1"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_Transaction">
    <bpmndi:BPMNPlane bpmnElement="Transaction" id="BPMNPlane_Transaction">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="20.0" y="290.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
        <omgdc:Bounds height="55.0" width="105.0" x="122.0" y="280.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="boundarytimer2" id="BPMNShape_boundarytimer2">
        <omgdc:Bounds height="30.0" width="30.0" x="160.0" y="326.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="860.0" y="250.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="subprocess1" id="BPMNShape_subprocess1">
        <omgdc:Bounds height="221.0" width="641.0" x="310.0" y="197.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask2" id="BPMNShape_usertask2">
        <omgdc:Bounds height="55.0" width="105.0" x="400.0" y="282.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="startevent2" id="BPMNShape_startevent2">
        <omgdc:Bounds height="35.0" width="35.0" x="320.0" y="292.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask5" id="BPMNShape_usertask5">
        <omgdc:Bounds height="55.0" width="105.0" x="670.0" y="228.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="errorendevent1" id="BPMNShape_errorendevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="705.0" y="350.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent2" id="BPMNShape_endevent2">
        <omgdc:Bounds height="35.0" width="35.0" x="900.0" y="302.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="parallelgateway1" id="BPMNShape_parallelgateway1">
        <omgdc:Bounds height="40.0" width="40.0" x="550.0" y="289.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="boundaryerror1" id="BPMNShape_boundaryerror1">
        <omgdc:Bounds height="30.0" width="30.0" x="760.0" y="400.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask4" id="BPMNShape_usertask4">
        <omgdc:Bounds height="55.0" width="105.0" x="1150.0" y="280.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask3" id="BPMNShape_usertask3">
        <omgdc:Bounds height="55.0" width="105.0" x="1010.0" y="280.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent3" id="BPMNShape_endevent3">
        <omgdc:Bounds height="35.0" width="35.0" x="1290.0" y="290.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask6" id="BPMNShape_usertask6">
        <omgdc:Bounds height="55.0" width="105.0" x="640.0" y="470.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="55.0" y="307.0"></omgdi:waypoint>
        <omgdi:waypoint x="122.0" y="307.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
        <omgdi:waypoint x="722.0" y="283.0"></omgdi:waypoint>
        <omgdi:waypoint x="917.0" y="302.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow13" id="BPMNEdge_flow13">
        <omgdi:waypoint x="355.0" y="309.0"></omgdi:waypoint>
        <omgdi:waypoint x="400.0" y="309.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow17" id="BPMNEdge_flow17">
        <omgdi:waypoint x="505.0" y="309.0"></omgdi:waypoint>
        <omgdi:waypoint x="550.0" y="309.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow18" id="BPMNEdge_flow18">
        <omgdi:waypoint x="570.0" y="289.0"></omgdi:waypoint>
        <omgdi:waypoint x="570.0" y="255.0"></omgdi:waypoint>
        <omgdi:waypoint x="670.0" y="255.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow19" id="BPMNEdge_flow19">
        <omgdi:waypoint x="570.0" y="329.0"></omgdi:waypoint>
        <omgdi:waypoint x="569.0" y="367.0"></omgdi:waypoint>
        <omgdi:waypoint x="705.0" y="367.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
        <omgdi:waypoint x="227.0" y="307.0"></omgdi:waypoint>
        <omgdi:waypoint x="310.0" y="307.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8">
        <omgdi:waypoint x="951.0" y="307.0"></omgdi:waypoint>
        <omgdi:waypoint x="1010.0" y="307.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow9" id="BPMNEdge_flow9">
        <omgdi:waypoint x="1115.0" y="307.0"></omgdi:waypoint>
        <omgdi:waypoint x="1150.0" y="307.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow10" id="BPMNEdge_flow10">
        <omgdi:waypoint x="1255.0" y="307.0"></omgdi:waypoint>
        <omgdi:waypoint x="1290.0" y="307.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow11" id="BPMNEdge_flow11">
        <omgdi:waypoint x="775.0" y="430.0"></omgdi:waypoint>
        <omgdi:waypoint x="774.0" y="496.0"></omgdi:waypoint>
        <omgdi:waypoint x="745.0" y="497.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow15" id="BPMNEdge_flow15">
        <omgdi:waypoint x="175.0" y="356.0"></omgdi:waypoint>
        <omgdi:waypoint x="174.0" y="590.0"></omgdi:waypoint>
        <omgdi:waypoint x="821.0" y="590.0"></omgdi:waypoint>
        <omgdi:waypoint x="1307.0" y="590.0"></omgdi:waypoint>
        <omgdi:waypoint x="1307.0" y="325.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="14.0" width="48.0" x="356.0" y="569.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow16" id="BPMNEdge_flow16">
        <omgdi:waypoint x="640.0" y="497.0"></omgdi:waypoint>
        <omgdi:waypoint x="573.0" y="497.0"></omgdi:waypoint>
        <omgdi:waypoint x="630.0" y="418.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>



在userTask2   activiti:class 中配置Class  路径

package com.activiti;

import org.activiti.engine.delegate.BpmnError;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.JavaDelegate;

public class SecondTestRunningTask implements JavaDelegate {

	public void execute(DelegateExecution execution) throws Exception {
		// TODO Auto-generated method stub
		System.out.println("我进来了");
		throw new BpmnError("error_99");
	}
	

}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值