gpt4 book ai didi

java - Flowable 异常后流程不会继续

转载 作者:行者123 更新时间:2023-12-01 18:50:59 48 4
gpt4 key购买 nike

根据下面的流程,在基数 = 5 的情况下并行执行“simpleLog”(异步)服务任务时,我们遇到了并发问题,此后流程不再继续执行“dummy”(独占)服务任务下一步也不会重试“simpleLog”中的作业。相反,我们得到 4 FlowableOptimisticLockingException。详细来说,“simpleLog”仅打印一些硬编码字符串, hibernate 3 秒(以模拟真实任务)并显示另一个硬编码字符串。 “dummy”显示另一个文本,“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>

最佳答案

查看配置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 中提出问题关于这个问题。在这种情况下,我们可以做一个潜在的改进,使您的作业能够真正并行运行,然后 Activity 的合并发生在不同的异步独占作业中。

关于java - Flowable 异常后流程不会继续,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59739553/

48 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com