我正在从Activiti版本5.21迁移到6.0.0。除了预期的更改(一些意外),我在执行异步邮件任务时遇到了一个有趣的问题。 Mail任务按预期发送消息,并且不会引发任何错误,但是尽管操作成功,但仍会出现重试失败流。在3次尝试(和3封电子邮件发送)后,作业移动到死信表,就好像发生了错误一样。表中的错误消息是
“JobEntity [id = SOME ID]由另一个事务同时更新”
奇怪的是,Activiti没有抛出任何错误。我已经将我的日志级别设置为跟踪,似乎没有任何异常。
根据用户指南(https://www.activiti.org/userguide/#failRetry),如果出现故障,我会尝试重试该操作,但在这种情况下,没有任何内容失败并且邮件已正确发送。
如果我将Process config AsyncExecutorNumberOfRetries属性设置为零(configurationImpl.setAsyncExecutorNumberOfRetries(0);),我可以避免此错误,但这似乎不是我应该做的事情。
ProcessEngineConfigurationImpl中asyncExecutorNumberOfRetries属性的默认值为3,因此解释了3次尝试,但我想知道为什么引擎没有捕获成功的邮件事件并将其视为失败。
这是我的bpmn模型代码:它只是一个简单的开始/结束事件,包含电子邮件和即席任务。
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:activity="http://activiti.org/bpmn" xmlns:klover="http://klover.io/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn">
<bpmn:process id="MigrationTest3" name="Migration Test 3" isExecutable="true" klover:category="tenant1|Incident:TaskCategoryType">
<bpmn:documentation>test 3</bpmn:documentation>
<bpmn:startEvent id="StartEvent_1" name="Start Event" activity:initiator="initiator">
<bpmn:documentation>This element denotes the start of the process instance</bpmn:documentation>
<bpmn:outgoing>SequenceFlow_0xdrrlx</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:serviceTask id="ServiceTask_0p317lq" name="MIgration Test 3" activity:async="true" activity:type="mail">
<bpmn:documentation>This element denotes the service to send email</bpmn:documentation>
<bpmn:extensionElements>
<activity:field name="from">
<activity:expression></activity:expression>
</activity:field>
<activity:field name="to">
<activity:expression>me@test.org</activity:expression>
</activity:field>
<activity:field name="subject">
<activity:expression>Test Migration 3</activity:expression>
</activity:field>
<activity:field name="text">
<activity:expression>testing re-enabling async mail task - did this send 3 times?</activity:expression>
</activity:field>
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_0xdrrlx</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0wboybt</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:endEvent id="EndEvent_11vu7d5" name="Undefined End Event">
<bpmn:documentation>This element denotes the end of the process instance</bpmn:documentation>
<bpmn:incoming>SequenceFlow_17ff3nr</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_0xdrrlx" sourceRef="StartEvent_1" targetRef="ServiceTask_0p317lq" />
<bpmn:sequenceFlow id="SequenceFlow_0wboybt" sourceRef="ServiceTask_0p317lq" targetRef="UserTask_1sghk67" />
<bpmn:userTask id="UserTask_1sghk67" name="Testing Adhoc task after email" activity:assignee="tenant1|718abdcf-e192-11e5-b7f0-9f235e785c94" activity:priority="0" klover:formType="Adhoc">
<bpmn:documentation>Testing the new execution id change</bpmn:documentation>
<bpmn:incoming>SequenceFlow_0wboybt</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_17ff3nr</bpmn:outgoing>
</bpmn:userTask>
<bpmn:sequenceFlow id="SequenceFlow_17ff3nr" sourceRef="UserTask_1sghk67" targetRef="EndEvent_11vu7d5" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="MigrationTest3">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="44" y="84" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="34" y="120" width="55" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ServiceTask_0p317lq_di" bpmnElement="ServiceTask_0p317lq">
<dc:Bounds x="285" y="128" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="EndEvent_11vu7d5_di" bpmnElement="EndEvent_11vu7d5">
<dc:Bounds x="663" y="281" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="644" y="317" width="74" height="24" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_0xdrrlx_di" bpmnElement="SequenceFlow_0xdrrlx">
<di:waypoint xsi:type="dc:Point" x="80" y="102" />
<di:waypoint xsi:type="dc:Point" x="183" y="102" />
<di:waypoint xsi:type="dc:Point" x="183" y="168" />
<di:waypoint xsi:type="dc:Point" x="285" y="168" />
<bpmndi:BPMNLabel>
<dc:Bounds x="198" y="125" width="0" height="0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0wboybt_di" bpmnElement="SequenceFlow_0wboybt">
<di:waypoint xsi:type="dc:Point" x="385" y="168" />
<di:waypoint xsi:type="dc:Point" x="452" y="168" />
<di:waypoint xsi:type="dc:Point" x="452" y="207" />
<di:waypoint xsi:type="dc:Point" x="453" y="259" />
<bpmndi:BPMNLabel>
<dc:Bounds x="467" y="187.5" width="0" height="0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="UserTask_1sghk67_di" bpmnElement="UserTask_1sghk67">
<dc:Bounds x="403" y="259" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_17ff3nr_di" bpmnElement="SequenceFlow_17ff3nr">
<di:waypoint xsi:type="dc:Point" x="503" y="299" />
<di:waypoint xsi:type="dc:Point" x="581" y="299" />
<di:waypoint xsi:type="dc:Point" x="581" y="299" />
<di:waypoint xsi:type="dc:Point" x="663" y="299" />
<bpmndi:BPMNLabel>
<dc:Bounds x="596" y="299" width="0" height="0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
任何建议都将不胜感激!
答案 0 :(得分:0)
原来问题是,在我们的DEV环境中,当每个开发人员正在处理应用程序时,我们会启动流程引擎的多个实例。由于我是当时唯一工作的人,最初我并不认为这是问题所在。事实证明我们有一个运行引擎的旧应用服务器。随后,它在AWS上的运行时间与本地实例不同。这是导致感知失败的原因,因为此AWS实例上的锁定时间为UTC,并且我在本地MST上运行。
设置包含的本地环境后,我的异步邮件任务按预期执行... 1次