首页 > 其他分享 >Flowable-排他网关

Flowable-排他网关

时间:2024-02-20 14:22:53浏览次数:21  
标签:网关 顺序 Flowable 流程 admin assigneeUserId condition

排他网关只会选择一条顺序流,即当流程到达排他网关这个节点时,会按顺序(XML中定义的前后顺序)选择出口顺序流(sequenceFlow)计算其定义的条件,如果被计算的条件为True,则按照该出口顺序流向下执行。如果所有出口顺序流的条件都为False,则会抛出异常。

在流程设计器内,排他网关位于Gateways内,其英文名称为Exclusive gateway,如下图所示:

img

下面就以一个简单流程实验一下排他网关的用法,流程图如下:

img

由排他网关到达用户任务2的Flow condition设置为:

${assigneeUserId != "admin"}

由排他网关到达用户任务3的Flow condition设置为:

${assigneeUserId == "admin"}

启动流程时如下设置:

map.put("assigneeUserId", "admin");
runtimeService.startProcessInstanceByKey(modelData.getKey(), "myTestFlow1", map);

整体的流程运行如下:

img启动后

img通过排他网关后

可以看到,由排他网关到达用户任务3的Flow condition为True,所以流程会自动流转至对应的节点。

如果新加入一个节点,如下图:

img

由排他网关到达用户任务4的Flow condition设置为:

${assigneeUserId == "admin"}

然后再启动流程,此时流程到达排他网关的流转规则会按照XML中的顺序流转,如下图所示:

img

实际运行时的结果也是如此:

img

如果将用户任务3和用户任务4的Flow condition设置为:

${assigneeUserId != "admin"}

此时,再次启动流程,并流转,将输出异常:

org.springframework.web.util.NestedServletException: Request processing failed; 
nested exception is org.flowable.common.engine.api.FlowableException: 
No outgoing sequence flow of the exclusive gateway 'sid-07951B0A-225A-440C-A8C9-60D7C00E962F' could be selected for continuing the process

大概的意思就是:

排他网关没有任何向外路径,流程无法流转。

以上,相继介绍了排他网关的用法、条件生效的顺序、全都不符合条件时所产生的异常。

可以点击”阅读原文“查看流程的XML文件,如有错误欢迎指出和讨论。

附件,流程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.activiti.org/processdef">
  <process id="ExclusiveGatewayFlowTest" name="测试排他网关" isExecutable="true">
    <startEvent id="StartEvent" name="开始"></startEvent>
    <userTask id="UserTask1" name="处理"></userTask>
    <sequenceFlow id="sid-20EF43C5-7147-4275-9EB8-7E86639DCE0A" sourceRef="StartEvent" targetRef="UserTask1"></sequenceFlow>
    <exclusiveGateway id="sid-07951B0A-225A-440C-A8C9-60D7C00E962F"></exclusiveGateway>
    <sequenceFlow id="sid-43D498C5-E475-4C0B-8EF7-5144EADA2C14" sourceRef="UserTask1" targetRef="sid-07951B0A-225A-440C-A8C9-60D7C00E962F"></sequenceFlow>
    <userTask id="UserTask3" name="用户任务3"></userTask>
    <userTask id="UserTask2" name="用户任务2"></userTask>
    <endEvent id="EndEvent1" name="结束1"></endEvent>
    <sequenceFlow id="sid-03A9DF99-5757-4881-A490-0A4586751EA5" sourceRef="UserTask2" targetRef="EndEvent1"></sequenceFlow>
    <endEvent id="EndEvent2" name="结束2"></endEvent>
    <sequenceFlow id="sid-676620AA-77A8-4F19-8506-13D8C3EFF0C5" sourceRef="sid-07951B0A-225A-440C-A8C9-60D7C00E962F" targetRef="UserTask2">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${assigneeUserId != "admin"}]]></conditionExpression>
    </sequenceFlow>
    <userTask id="UserTask4" name="用户任务4"></userTask>
    <sequenceFlow id="sid-E588F005-EA80-4F0A-8C2C-0B1B7F614912" sourceRef="UserTask3" targetRef="EndEvent2"></sequenceFlow>
    <endEvent id="sid-05A5A92E-290B-423B-97C9-9EEB2112BF2D"></endEvent>
    <sequenceFlow id="sid-99C7170B-304F-4A86-8428-5BE5DDBE8073" sourceRef="UserTask4" targetRef="sid-05A5A92E-290B-423B-97C9-9EEB2112BF2D"></sequenceFlow>
    <sequenceFlow id="sid-EDA1F094-3B70-42E5-8E94-49A01480EF90" sourceRef="sid-07951B0A-225A-440C-A8C9-60D7C00E962F" targetRef="UserTask3">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${assigneeUserId == "admin"}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="sid-61511D8E-0C8E-4F03-BA4B-17531892C95D" sourceRef="sid-07951B0A-225A-440C-A8C9-60D7C00E962F" targetRef="UserTask4">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${assigneeUserId == "admin"}]]></conditionExpression>
    </sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_ExclusiveGatewayFlowTest">
    <bpmndi:BPMNPlane bpmnElement="ExclusiveGatewayFlowTest" id="BPMNPlane_ExclusiveGatewayFlowTest">
      <bpmndi:BPMNShape bpmnElement="StartEvent" id="BPMNShape_StartEvent">
        <omgdc:Bounds height="30.0" width="30.0" x="120.0" y="114.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="UserTask1" id="BPMNShape_UserTask1">
        <omgdc:Bounds height="80.0" width="100.0" x="195.0" y="89.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-07951B0A-225A-440C-A8C9-60D7C00E962F" id="BPMNShape_sid-07951B0A-225A-440C-A8C9-60D7C00E962F">
        <omgdc:Bounds height="40.0" width="40.0" x="330.0" y="109.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="UserTask3" id="BPMNShape_UserTask3">
        <omgdc:Bounds height="80.0" width="100.0" x="405.0" y="285.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="UserTask2" id="BPMNShape_UserTask2">
        <omgdc:Bounds height="80.0" width="100.0" x="405.0" y="30.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="EndEvent1" id="BPMNShape_EndEvent1">
        <omgdc:Bounds height="28.0" width="28.0" x="550.0" y="56.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="EndEvent2" id="BPMNShape_EndEvent2">
        <omgdc:Bounds height="28.0" width="28.0" x="550.0" y="311.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="UserTask4" id="BPMNShape_UserTask4">
        <omgdc:Bounds height="80.0" width="100.0" x="405.0" y="135.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-05A5A92E-290B-423B-97C9-9EEB2112BF2D" id="BPMNShape_sid-05A5A92E-290B-423B-97C9-9EEB2112BF2D">
        <omgdc:Bounds height="28.0" width="28.0" x="550.0" y="161.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="sid-03A9DF99-5757-4881-A490-0A4586751EA5" id="BPMNEdge_sid-03A9DF99-5757-4881-A490-0A4586751EA5">
        <omgdi:waypoint x="504.9499999999792" y="70.0"></omgdi:waypoint>
        <omgdi:waypoint x="550.0" y="70.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-E588F005-EA80-4F0A-8C2C-0B1B7F614912" id="BPMNEdge_sid-E588F005-EA80-4F0A-8C2C-0B1B7F614912">
        <omgdi:waypoint x="504.95000000000005" y="325.0"></omgdi:waypoint>
        <omgdi:waypoint x="550.0" y="325.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-676620AA-77A8-4F19-8506-13D8C3EFF0C5" id="BPMNEdge_sid-676620AA-77A8-4F19-8506-13D8C3EFF0C5">
        <omgdi:waypoint x="350.5" y="109.5"></omgdi:waypoint>
        <omgdi:waypoint x="350.5" y="70.0"></omgdi:waypoint>
        <omgdi:waypoint x="405.0" y="70.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-61511D8E-0C8E-4F03-BA4B-17531892C95D" id="BPMNEdge_sid-61511D8E-0C8E-4F03-BA4B-17531892C95D">
        <omgdi:waypoint x="350.5" y="148.42922149122805"></omgdi:waypoint>
        <omgdi:waypoint x="350.5" y="175.0"></omgdi:waypoint>
        <omgdi:waypoint x="405.0" y="175.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-99C7170B-304F-4A86-8428-5BE5DDBE8073" id="BPMNEdge_sid-99C7170B-304F-4A86-8428-5BE5DDBE8073">
        <omgdi:waypoint x="504.94999999999595" y="175.0"></omgdi:waypoint>
        <omgdi:waypoint x="550.0" y="175.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-20EF43C5-7147-4275-9EB8-7E86639DCE0A" id="BPMNEdge_sid-20EF43C5-7147-4275-9EB8-7E86639DCE0A">
        <omgdi:waypoint x="149.9499984899576" y="129.0"></omgdi:waypoint>
        <omgdi:waypoint x="194.9999999999917" y="129.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-EDA1F094-3B70-42E5-8E94-49A01480EF90" id="BPMNEdge_sid-EDA1F094-3B70-42E5-8E94-49A01480EF90">
        <omgdi:waypoint x="350.5" y="148.44515593047032"></omgdi:waypoint>
        <omgdi:waypoint x="350.5" y="325.0"></omgdi:waypoint>
        <omgdi:waypoint x="405.0" y="325.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-43D498C5-E475-4C0B-8EF7-5144EADA2C14" id="BPMNEdge_sid-43D498C5-E475-4C0B-8EF7-5144EADA2C14">
        <omgdi:waypoint x="294.95000000000005" y="129.2367298578199"></omgdi:waypoint>
        <omgdi:waypoint x="330.4047619047619" y="129.40476190476193"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

标签:网关,顺序,Flowable,流程,admin,assigneeUserId,condition
From: https://www.cnblogs.com/bugDiDiDi/p/18022973

相关文章

  • .net core微服务之网关
    网关:一:apisixdoc:https://apisix.apache.org/zh/docs/apisix/getting-started/README/github:https://github.com/apache/apisix二:Konggithub:https://github.com/Kong/kong三:Ocelotgithub:https://github.com/ThreeMammals/Ocelot四:janusgithub:https://......
  • 配置springcloud 网关gateway 转发websocket请求
    网关是整个项目的统一入口这是直接访问消息服务的请求路径端口号是20007WebSocketService.init("ws://127.0.0.1:20007/ws/"+用户id)显然这样是不符合微服务的方案,所有请求必须经过网关处理,转发到各个服务之中所以我们需要在网关中的yml或者nacos中添加以下配置spring:......
  • 抛弃Spring Cloud Gateway,得物 使用Netty架构100Wqps网关
    文章很长,且持续更新,建议收藏起来,慢慢读!疯狂创客圈总目录博客园版为您奉上珍贵的学习资源:免费赠送:《尼恩Java面试宝典》持续更新+史上最全+面试必备2000页+面试必备+大厂必备+涨薪必备免费赠送:《尼恩技术圣经+高并发系列PDF》,帮你实现技术自由,完成职业升级,薪......
  • 面向网关、辅助和自动驾驶系统的汽车域控制器参考设计
    面向网关、辅助和自动驾驶系统的汽车域控制器参考设计说明当今道路上的分布式车辆架构使用单个ECU,缺少处理能力和高速接口,无法应对新兴汽车架构的复杂任务和数据移动需求。更高级别的功能需要正确组合DMIPS、数据带宽和功效。Jacinto™7处理器系列中的DRA829V和TDA4VM处......
  • Java中的审批流:BPMN与Flowable
    最近闲来无事,研究了一下工作流框架。找到了一条可以实现审批流程的技术方向。我选择的后端工作流框架是Flowable,看文档应该是属于Activity的一个分支吧。使用教程文档地址在:GettingStarted·FlowableOpenSourceDocumentation(用百度/必应搜索,搜到的是Flowable的官网,最后这个......
  • 使用ocelot 配置网关
    3.1场景描述建3个站点,2个微服务站点,1个网关微服务1:https://localhost:7227/微服务2:https://localhost:7019/网关:https://localhost:7055/在浏览器里访问 https://localhost:7227/api/Product/test1会输出test1在浏览器里访问https://localhost:7019/api/order/test2会输......
  • 什么是微服务的网关?
    假如有10个微服务,地址分部是:http://service1.abc.comhttp://service2.abc.comhttp://service3.abc.com................................................http://service10.abc.com网关:http://gatway.abc.com (在这个站点的appsetting.json里配置和微服务之间的映射)最后......
  • Profinet转CANopen主站网关与堡盟编码器通讯案例
    Profinet转CANopen主站网关与堡盟编码器通讯案例Profinet转CANopen主站网关(XD-COPNm20)为CPU与堡盟编码器的通讯提供了CANopen协议向Profinet协议转换互通的桥梁。CANopen是一种基于CAN总线的通讯协议,它被广泛应用于工业自动化领域,而Profinet是一种以太网协议,其优点是高速传输和......
  • profinet转CANopen网关在博图的profinet从站配置步骤
    profinet转CANopen网关在博图的profinet从站配置步骤Profinet转CANopen网关(XD-COPNm20)是一种用于实现CANopen设备与Profinet网络连接起来进行设备之间的数据交换和通信的设备。CANopen和Profinet是两种常见的工业通信协议,它们在自动化控制系统中有着广泛的应用。因此CANopen转Pro......
  • FastGateway 一个可以用于代替Nginx的网关
    在我本人研究Yarp的时候经常用于公司项目的业务网关代理,这时候就个大佬问我是否可以实现动态加载HTTPS证书?那时候我说不太可能实现,然而在某一天我看到微软使用Yarp代替了Nginx吞吐量提升了百分之八十!这个时候我就萌生了自己使用yarp造一个Gateway的项目,应为我本身也经常使用ngi......