在发生可流动异常后,流动不会继续

时间:2020-01-14 18:13:49

标签: java spring-boot bpmn flowable

鉴于以下流程,在以基数= 5并行执行“ simpleLog”(异步)服务任务时,我们遇到了并发问题,此后,流程不再继续执行“虚拟”(专有)服务任务。下一步也不要在“ simpleLog”中重试该作业。相反,我们得到4 FlowableOptimisticLockingException。 详细来说,“ simpleLog”仅打印一些硬编码的字符串,休眠3秒(以模拟真实任务),并显示另一个硬编码的字符串。 “虚拟”显示另一个文本,“ finalLog”显示所有全局变量。 这有什么问题吗?应该在FlowableOptimisticLockingException之后重试flowable 3次,如我们在这里阅读的:https://flowable.com/open-source/docs/bpmn/ch07b-BPMN-Constructs/#fail-retry吗?为什么流程不继续?

我们试图测试它是否像此处注释的那样工作:如何使一个多实例任务并行执行?但是我们没有成功。

enter image description here

<?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.flowable.org/processdef">
  <process id="parallelServicetask" name="parallelServicetask" isExecutable="true">
    <startEvent id="startEvent1" flowable:formFieldValidation="true"></startEvent>
    <serviceTask id="first" name="first" flowable:class="ar.com.telecom.st.pltesting.orquestador.delegates.loop.First"></serviceTask>
    <serviceTask id="finalLog" name="finalLog" flowable:class="ar.com.telecom.st.pltesting.orquestador.delegates.loop.Log"></serviceTask>
    <sequenceFlow id="sid-B08D33F0-4802-4AF7-AC57-826CCFC59F02" sourceRef="startEvent1" targetRef="first"></sequenceFlow>
    <endEvent id="sid-0E47B37E-2BDD-4DC5-82F5-91A35E90F0FC"></endEvent>
    <sequenceFlow id="sid-B2EDAC42-2DB8-4E99-B629-5FCBD0B8C9D4" sourceRef="sid-5819B32A-B13B-49D8-97A6-D409A81AFB64" targetRef="finalLog"></sequenceFlow>
    <subProcess id="sid-5819B32A-B13B-49D8-97A6-D409A81AFB64" name="subProcess">
      <serviceTask id="simpleLog" name="simpleLog" flowable:async="true" flowable:exclusive="false" flowable:class="ar.com.telecom.st.pltesting.orquestador.delegates.loop.LogThread">
        <multiInstanceLoopCharacteristics isSequential="false">
          <loopCardinality>5</loopCardinality>
        </multiInstanceLoopCharacteristics>
      </serviceTask>
      <serviceTask id="dummy" name="dummy" flowable:class="ar.com.telecom.st.pltesting.orquestador.delegates.loop.Dummy"></serviceTask>
      <startEvent id="sid-1F707CB9-593C-4135-8C53-A2E1EF5ECFD3" flowable:formFieldValidation="true"></startEvent>
      <endEvent id="sid-AE499CE0-482D-4B2F-A2BC-3CEEC24AD8B9"></endEvent>
      <sequenceFlow id="sid-86F155DC-5098-4803-A774-2E0E519671E0" sourceRef="dummy" targetRef="sid-AE499CE0-482D-4B2F-A2BC-3CEEC24AD8B9"></sequenceFlow>
      <sequenceFlow id="sid-0E862BB9-F8B5-4C4D-9DF8-EFDAC049FB51" sourceRef="sid-1F707CB9-593C-4135-8C53-A2E1EF5ECFD3" targetRef="simpleLog"></sequenceFlow>
      <sequenceFlow id="sid-5B2902A3-8F34-4044-8760-2586187F50AF" sourceRef="simpleLog" targetRef="dummy"></sequenceFlow>
    </subProcess>
    <sequenceFlow id="sid-5FE1F875-3C70-4C44-9593-013C0CF96C82" sourceRef="finalLog" targetRef="sid-0E47B37E-2BDD-4DC5-82F5-91A35E90F0FC"></sequenceFlow>
    <sequenceFlow id="sid-F442D23D-60F5-419F-8131-AB1E780BE326" sourceRef="first" targetRef="sid-5819B32A-B13B-49D8-97A6-D409A81AFB64"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_parallelServicetask">
    <bpmndi:BPMNPlane bpmnElement="parallelServicetask" id="BPMNPlane_parallelServicetask">
      <bpmndi:BPMNShape bpmnElement="startEvent1" id="BPMNShape_startEvent1">
        <omgdc:Bounds height="29.99999999999997" width="30.000000000000007" x="63.225147766400106" y="254.02632989760096"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="first" id="BPMNShape_first">
        <omgdc:Bounds height="80.0" width="100.0" x="28.225147766400113" y="420.01594128181614"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="finalLog" id="BPMNShape_finalLog">
        <omgdc:Bounds height="80.0" width="100.0" x="1044.330467356804" y="420.01594128181614"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-0E47B37E-2BDD-4DC5-82F5-91A35E90F0FC" id="BPMNShape_sid-0E47B37E-2BDD-4DC5-82F5-91A35E90F0FC">
        <omgdc:Bounds height="28.0" width="28.0" x="1080.330467356804" y="620.9532508608023"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-5819B32A-B13B-49D8-97A6-D409A81AFB64" id="BPMNShape_sid-5819B32A-B13B-49D8-97A6-D409A81AFB64">
        <omgdc:Bounds height="396.6088081391821" width="756.9219009007616" x="214.41134932956686" y="260.7706994757856"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="simpleLog" id="BPMNShape_simpleLog">
        <omgdc:Bounds height="80.0" width="100.00000000000006" x="420.0" y="420.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="dummy" id="BPMNShape_dummy">
        <omgdc:Bounds height="80.0" width="100.0" x="660.0" y="420.01594128181614"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-1F707CB9-593C-4135-8C53-A2E1EF5ECFD3" id="BPMNShape_sid-1F707CB9-593C-4135-8C53-A2E1EF5ECFD3">
        <omgdc:Bounds height="30.0" width="30.0" x="257.9999999999999" y="444.07510354537663"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="sid-AE499CE0-482D-4B2F-A2BC-3CEEC24AD8B9" id="BPMNShape_sid-AE499CE0-482D-4B2F-A2BC-3CEEC24AD8B9">
        <omgdc:Bounds height="28.0" width="28.0" x="909.9999999999999" y="446.01594128181614"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="sid-86F155DC-5098-4803-A774-2E0E519671E0" id="BPMNEdge_sid-86F155DC-5098-4803-A774-2E0E519671E0">
        <omgdi:waypoint x="759.9499999999999" y="460.01594128181614"></omgdi:waypoint>
        <omgdi:waypoint x="909.9999999999999" y="460.01594128181614"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-B08D33F0-4802-4AF7-AC57-826CCFC59F02" id="BPMNEdge_sid-B08D33F0-4802-4AF7-AC57-826CCFC59F02">
        <omgdi:waypoint x="78.22514776640011" y="283.97632939653414"></omgdi:waypoint>
        <omgdi:waypoint x="78.22514776640011" y="420.01594128181614"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-5B2902A3-8F34-4044-8760-2586187F50AF" id="BPMNEdge_sid-5B2902A3-8F34-4044-8760-2586187F50AF">
        <omgdi:waypoint x="519.95" y="460.003317779278"></omgdi:waypoint>
        <omgdi:waypoint x="660.0" y="460.0126201814378"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-F442D23D-60F5-419F-8131-AB1E780BE326" id="BPMNEdge_sid-F442D23D-60F5-419F-8131-AB1E780BE326">
        <omgdi:waypoint x="128.17514776635966" y="459.9245351861292"></omgdi:waypoint>
        <omgdi:waypoint x="214.4113493295555" y="459.76688489629385"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-0E862BB9-F8B5-4C4D-9DF8-EFDAC049FB51" id="BPMNEdge_sid-0E862BB9-F8B5-4C4D-9DF8-EFDAC049FB51">
        <omgdi:waypoint x="287.9498208930293" y="459.14529174490895"></omgdi:waypoint>
        <omgdi:waypoint x="419.99999999999966" y="459.7652547069484"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-5FE1F875-3C70-4C44-9593-013C0CF96C82" id="BPMNEdge_sid-5FE1F875-3C70-4C44-9593-013C0CF96C82">
        <omgdi:waypoint x="1094.330467356804" y="499.9659412818162"></omgdi:waypoint>
        <omgdi:waypoint x="1094.330467356804" y="620.9532508608023"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sid-B2EDAC42-2DB8-4E99-B629-5FCBD0B8C9D4" id="BPMNEdge_sid-B2EDAC42-2DB8-4E99-B629-5FCBD0B8C9D4">
        <omgdi:waypoint x="971.2832502303205" y="459.78507962131937"></omgdi:waypoint>
        <omgdi:waypoint x="1044.330467356804" y="459.922131090132"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

1 个答案:

答案 0 :(得分:0)

查看配置simpleLog服务任务

<serviceTask id="simpleLog" name="simpleLog" flowable:async="true" flowable:exclusive="false" flowable:class="ar.com.telecom.st.pltesting.orquestador.delegates.loop.LogThread">
    <multiInstanceLoopCharacteristics isSequential="false">
        <loopCardinality>5</loopCardinality>
    </multiInstanceLoopCharacteristics>
</serviceTask>

它具有flowable:exclusive="false",这意味着所有(5)个服务任务将并行运行。完成逻辑后,所有这些将继续并尝试合并多实例。合并发生时,所有线程将尝试更新同一实体。其中只有一个会成功,而您将有4个FlowableOptimisticLockingException(一个会成功)。

此后,4会再次尝试导致3引发异常,然后3会再次尝试导致2引发异常并最终导致死锁(我认为这是对您的影响)。

目前唯一避免此问题的方法是使用flowable:exclusive="true",它不是真正并行的,因为在任何给定时间仅执行一个服务任务。

我建议您在Flowable issue tracker中打开一个与此问题有关的问题。在这种情况下,我们可以做一些潜在的改进,使您的作业真正并行运行,但随后将活动合并到另一个异步独占作业中。