糖尿病康复,内容丰富有趣,生活中的好帮手!
糖尿病康复 > Flowable边界事件-取消边界事件

Flowable边界事件-取消边界事件

时间:2019-01-28 12:55:52

相关推荐

Flowable边界事件-取消边界事件

取消边界事件

取消边界事件一、定义1. 图形标记2. 配合取消结束事件使用3. XML标记 二、测试用例2.1 取消边界事件xml文件2.2 取消边界事件测试用例 总结视频地址:演示demo

取消边界事件

一、定义

接收到取消命令触发事件

取消边界事情只能在事务子流程中使用,并配合取消结束事件触发

1. 图形标记

2. 配合取消结束事件使用

3. XML标记

错误边界事件的XML

<boundaryEvent id="Event_0lxd35r" attachedToRef="Activity_1vnyjkd"><cancelEventDefinition /></boundaryEvent>

二、测试用例

2.1 取消边界事件xml文件

<?xml version="1.0" encoding="UTF-8"?><definitions xmlns="/spec/BPMN/0524/MODEL" xmlns:xsi="/2001/XMLSchema-instance" xmlns:flowable="/bpmn" xmlns:bpmndi="/spec/BPMN/0524/DI" xmlns:omgdc="/spec/DD/0524/DC" xmlns:omgdi="/spec/DD/0524/DI" xmlns:xsd="/2001/XMLSchema" targetNamespace="/bpmn"><error id="errorFlag" errorCode="500" /><process id="ThransactionSubProcessTest" name="子流程-事务子流程" isExecutable="true"><startEvent id="a1bc9933739624c6694151aff2dce872b" /><userTask id="aa49686c18f1c48879976ba75a55fcbc6" name="用户提交订单"><extensionElements><flowable:formData /><flowable:assigneeType>static</flowable:assigneeType></extensionElements></userTask><sequenceFlow id="ab3c3111802e74e1c829879ce06ef62f1" sourceRef="a1bc9933739624c6694151aff2dce872b" targetRef="aa49686c18f1c48879976ba75a55fcbc6" /><transaction id="Activity_1vnyjkd" name="事务子流程"><startEvent id="Event_12nf6w8"><extensionElements><flowable:formData /></extensionElements></startEvent><sequenceFlow id="Flow_1qdwcnq" sourceRef="Event_12nf6w8" targetRef="Gateway_1swfvxl" /><parallelGateway id="Gateway_1swfvxl" /><sequenceFlow id="Flow_17rtq7v" sourceRef="Gateway_1swfvxl" targetRef="Activity_1gw2yen" /><serviceTask id="Activity_1gw2yen" name="锁定库存" flowable:class="com.dragon.test.bpmn.delegate.TreasuryLockService"><extensionElements><flowable:formData /><flowable:assigneeType>static</flowable:assigneeType></extensionElements></serviceTask><userTask id="Activity_0s32nn4" name="用户取消订单"><extensionElements><flowable:formData /><flowable:assigneeType>static</flowable:assigneeType></extensionElements></userTask><sequenceFlow id="Flow_0x4x7li" sourceRef="Gateway_1swfvxl" targetRef="Activity_0s32nn4" /><userTask id="Activity_0k0ojol" name="用户支付订单"><extensionElements><flowable:formData /><flowable:assigneeType>static</flowable:assigneeType></extensionElements></userTask><sequenceFlow id="Flow_107046y" sourceRef="Activity_1gw2yen" targetRef="Activity_0k0ojol" /><sequenceFlow id="Flow_1yuazgn" sourceRef="Activity_0k0ojol" targetRef="Activity_0bi67sc" /><serviceTask id="Activity_0bi67sc" name="扣减库存" flowable:class="com.dragon.test.bpmn.delegate.TreasuryDeductService"><extensionElements><flowable:assigneeType>static</flowable:assigneeType><flowable:formData /></extensionElements></serviceTask><endEvent id="Event_167temk" /><sequenceFlow id="Flow_0pkp6lj" sourceRef="Activity_0bi67sc" targetRef="Event_167temk" /><sequenceFlow id="Flow_12q7c71" sourceRef="Activity_0s32nn4" targetRef="Event_1mt0jp2" /><endEvent id="Event_1mt0jp2"><cancelEventDefinition /></endEvent><boundaryEvent id="Event_1w62z13" attachedToRef="Activity_0bi67sc"><errorEventDefinition errorRef="errorFlag" flowable:errorVariableLocalScope="false" flowable:errorVariableTransient="false" /></boundaryEvent><sequenceFlow id="Flow_03od54n" sourceRef="Event_1w62z13" targetRef="Event_1mt0jp2" /><boundaryEvent id="Event_0fblty6" name="30分钟" attachedToRef="Activity_0k0ojol"><timerEventDefinition><timeDuration>PT30M</timeDuration></timerEventDefinition></boundaryEvent><sequenceFlow id="Flow_0hmzy4u" sourceRef="Event_0fblty6" targetRef="Event_1mt0jp2" /><boundaryEvent id="Event_0dzq6vl" attachedToRef="Activity_1gw2yen"><compensateEventDefinition /></boundaryEvent><serviceTask id="Activity_15oy2bt" name="释放库存" isForCompensation="true" flowable:class="com.dragon.test.bpmn.delegate.TreasuryReleaseService" /><boundaryEvent id="Event_0rv7u1v" attachedToRef="Activity_0k0ojol"><compensateEventDefinition /></boundaryEvent><serviceTask id="Activity_0gw5xlk" name="费用退回" isForCompensation="true" flowable:class="com.dragon.test.bpmn.delegate.RefundPaymentService" /><association id="Association_1a1b669" associationDirection="One" sourceRef="Event_0dzq6vl" targetRef="Activity_15oy2bt" /><association id="Association_0vig570" associationDirection="One" sourceRef="Event_0rv7u1v" targetRef="Activity_0gw5xlk" /></transaction><sequenceFlow id="Flow_0ynhbof" sourceRef="aa49686c18f1c48879976ba75a55fcbc6" targetRef="Activity_1vnyjkd" /><boundaryEvent id="Event_0lxd35r" attachedToRef="Activity_1vnyjkd"><cancelEventDefinition /></boundaryEvent><sequenceFlow id="Flow_0p83e5j" sourceRef="Event_0lxd35r" targetRef="Activity_0xmvtli" /><serviceTask id="Activity_0xmvtli" name="自动取消订单" flowable:class="com.dragon.test.bpmn.delegate.CancelOrderService"><extensionElements><flowable:formData /><flowable:assigneeType>static</flowable:assigneeType></extensionElements></serviceTask><endEvent id="Event_0h8me6c" /><sequenceFlow id="Flow_1vvt0is" sourceRef="Activity_0xmvtli" targetRef="Event_0h8me6c" /><endEvent id="Event_1954lc4" /><sequenceFlow id="Flow_0kcxljy" sourceRef="Activity_1vnyjkd" targetRef="Event_1954lc4" /></process>

2.2 取消边界事件测试用例

SimplePropertyPreFilter executionFilter = new SimplePropertyPreFilter(Execution.class,"id","parentId","businessKey","processInstanceId","rootProcessInstanceId","scope","activityId");//部署流程ProcessDefinition processDefinition = deployByModelKey("ThransactionSubProcessTest");//设置主流程的流程变量Map variables1 = new HashMap<>();variables1.put("goodsNum", 100);variables1.put("orderCost", 1000);//发起流程ProcessInstance mainProcessInstance = runtimeService.startProcessInstanceById(processDefinition.getId(), variables1);//查询执行实例List<Execution> executionList1 = runtimeService.createExecutionQuery().processInstanceId(mainProcessInstance.getId()).list();log.info("主流程发起后,执行实例数为{},分别为:{}", executionList1.size(), JSON.toJSONString(executionList1, executionFilter));//查询主流程的流程变量Map mainProcessVariabes1 = runtimeService.getVariables(mainProcessInstance.getProcessInstanceId());log.info("主流程的流程变量为:{}", mainProcessVariabes1);//查询主流程第一个任务Task firstTaskOfMainProcess = taskService.createTaskQuery().processInstanceId(mainProcessInstance.getId()).singleResult();log.info("主流程发起后,流程当前所在用户任务为:{}", firstTaskOfMainProcess.getName());//完成主流程第一个任务log.info("办理用户任务:{},启动事务子流程", firstTaskOfMainProcess.getName());plete(firstTaskOfMainProcess.getId());//查询执行实例List<Execution> executionList2 = runtimeService.createExecutionQuery().processInstanceId(mainProcessInstance.getId()).list();log.info("子流程发起后,执行实例数为{},分别为:{}", executionList2.size(), JSON.toJSONString(executionList2, executionFilter));//查询子流程第一个任务Task firstTaskOfSubProcess = taskService.createTaskQuery().taskName("用户支付订单").processInstanceId(mainProcessInstance.getId()).includeProcessVariables().singleResult();log.info("子流程发起后,流程当前所在用户任务为:{}", firstTaskOfSubProcess.getName());//查询子流程的流程变量Map subProcessVariabes1 = firstTaskOfSubProcess.getProcessVariables();log.info("子流程的流程变量为:{}", subProcessVariabes1);log.info("办理用户任务:{}", firstTaskOfSubProcess.getName());//完成子流程第一个任务,后续到达服务节点plete(firstTaskOfSubProcess.getId());//查询执行实例List<Execution> executionList4 = runtimeService.createExecutionQuery().processInstanceId(mainProcessInstance.getId()).list();log.info("主流程结束后,执行实例数为{},执行实例信息为:{}", executionList4.size(), JSON.toJSONString(executionList4, executionFilter));

总结

取消边界事件只能在事务子流程中使用,并配合取消结束事件触发。

欢迎加入QQ群学习交流:58059

视频地址:

取消边界事件

演示demo

取消边界事件

本文中内容和案例出自贺波老师的书《深入Activiti流程引擎:核心原理与高阶实战》,书中的介绍更全面、详细,推荐给大家。

深入Activiti流程引擎

如果觉得《Flowable边界事件-取消边界事件》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。