Activiti-循环内多实例服务任务本身发生异常

时间:2018-08-02 14:06:19

标签: activiti bpmn

我有以下过程。在该过程中,存在一个多实例服务任务(MyProcess),它本身是循环的一部分。

BPMN Diagram

问题是Service Task 3完成后出现以下异常。

但是,如果我不将Service Task 3设置为多实例,或者如果我不将org.activiti.engine.impl.pvm.PvmException: already taking a transition at org.activiti.engine.impl.persistence.entity.ExecutionEntity.take(ExecutionEntity.java:453) ~[activiti-engine-5.22.0.jar:5.22.0] at org.activiti.engine.impl.persistence.entity.ExecutionEntity.take(ExecutionEntity.java:438) ~[activiti-engine-5.22.0.jar:5.22.0] at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performOutgoingBehavior(BpmnActivityBehavior.java:140) ~[activiti-engine-5.22.0.jar:5.22.0] at org.activiti.engine.impl.bpmn.behavior.BpmnActivityBehavior.performDefaultOutgoingBehavior(BpmnActivityBehavior.java:66) ~[activiti-engine-5.22.0.jar:5.22.0] at org.activiti.engine.impl.bpmn.behavior.FlowNodeActivityBehavior.leave(FlowNodeActivityBehavior.java:44) ~[activiti-engine-5.22.0.jar:5.22.0] at org.activiti.engine.impl.bpmn.behavior.SequentialMultiInstanceBehavior.leave(SequentialMultiInstanceBehavior.java:75) ~[activiti-engine-5.22.0.jar:5.22.0] at org.activiti.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior.execute(MultiInstanceActivityBehavior.java:98) ~[activiti-engine-5.22.0.jar:5.22.0] at org.activiti.engine.impl.bpmn.behavior.SequentialMultiInstanceBehavior.execute(SequentialMultiInstanceBehavior.java:90) ~[activiti-engine-5.22.0.jar:5.22.0] at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:60) ~[activiti-engine-5.22.0.jar:5.22.0] at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:97) ~[activiti-engine-5.22.0.jar:5.22.0] 设置为更大循环的一部分,则不会收到异常。因此,对于我提到的情况,例外情况正在发生。

<?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:activiti="http://activiti.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/test">
  <process id="myProcess" name="My process" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <endEvent id="endevent1" name="End"></endEvent>
    <serviceTask id="servicetask1" name="Service Task 1" activiti:delegateExpression="${serviceTask1}"></serviceTask>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="servicetask1"></sequenceFlow>
    <serviceTask id="servicetask2" name="Service Task 2" activiti:delegateExpression="${serviceTask2}"></serviceTask>
    <exclusiveGateway id="exclusivegateway1" name="Exclusive Gateway"></exclusiveGateway>
    <sequenceFlow id="flow2" sourceRef="servicetask1" targetRef="exclusivegateway1"></sequenceFlow>
    <sequenceFlow id="flow3" name="list not empty" sourceRef="exclusivegateway1" targetRef="servicetask2">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[{!isEmpty}]]></conditionExpression>
    </sequenceFlow>
    <serviceTask id="servicetask3" name="Service Task 3" activiti:delegateExpression="${serviceTask3}">
      <multiInstanceLoopCharacteristics isSequential="true" activiti:collection="myList" activiti:elementVariable="element"></multiInstanceLoopCharacteristics>
    </serviceTask>
    <sequenceFlow id="flow5" sourceRef="servicetask2" targetRef="servicetask3"></sequenceFlow>
    <sequenceFlow id="flow6" name="list empty" sourceRef="exclusivegateway1" targetRef="endevent1">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${myList.isEmpty()}]]></conditionExpression>
    </sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_myProcess">
    <bpmndi:BPMNPlane bpmnElement="myProcess" id="BPMNPlane_myProcess">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="180.0" y="250.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="443.0" y="360.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask1" id="BPMNShape_servicetask1">
        <omgdc:Bounds height="55.0" width="105.0" x="280.0" y="240.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask2" id="BPMNShape_servicetask2">
        <omgdc:Bounds height="55.0" width="105.0" x="576.0" y="240.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="exclusivegateway1" id="BPMNShape_exclusivegateway1">
        <omgdc:Bounds height="40.0" width="40.0" x="440.0" y="247.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask3" id="BPMNShape_servicetask3">
        <omgdc:Bounds height="55.0" width="105.0" x="576.0" y="130.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="215.0" y="267.0"></omgdi:waypoint>
        <omgdi:waypoint x="280.0" y="267.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="385.0" y="267.0"></omgdi:waypoint>
        <omgdi:waypoint x="440.0" y="267.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="480.0" y="267.0"></omgdi:waypoint>
        <omgdi:waypoint x="576.0" y="267.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="14.0" width="100.0" x="489.0" y="267.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
        <omgdi:waypoint x="628.0" y="240.0"></omgdi:waypoint>
        <omgdi:waypoint x="628.0" y="185.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
        <omgdi:waypoint x="460.0" y="287.0"></omgdi:waypoint>
        <omgdi:waypoint x="460.0" y="360.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="14.0" width="100.0" x="470.0" y="309.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

该xml是:

// all of this is inside a Xamarin.Forms Page 
public ViewModelObject ViewModel = new ViewModelObject();
BindingContext = ViewModel;

string SourceColumnName = "SourceColumn";
string TargetColumnName = "TargetColumn";
string ValueThatShowsTarget = "SomeValue";

Entry sourceEntry = new Entry();
// this binding works just fine
// entering something in sourceEntry changes ViewModel.SourceColumn
sourceEntry.SetBinding(Entry.TextProperty, SourceColumnName, BindingMode.TwoWay); 

Entry targetEntry = new Entry();
// this binding works just fine, although for this issue it is irrelevant
targetEntry.SetBinding(Entry.TextProperty, TargetColumnName, BindingMode.TwoWay); 
targetEntry.IsVisible = false;

var b = new Binding();                        
b.Source = ViewModel;
b.Path = SourceColumnName;
b.Mode = BindingMode.TwoWay;

var ss = new DataTrigger(typeof(Entry));
ss.Binding = b;
ss.Value = ValueThatShowsTarget;
ss.Setters.Add(new Setter{Property = Entry.IsVisibleProperty,Value = true});

targetEntry.Triggers.Add(ss);

Activiti版本是5.22.0。

任何人都遇到此问题并且可以提供帮助吗?

1 个答案:

答案 0 :(得分:2)

似乎是一个带有空集合的错误。

引用Activiti Ticket tracker (Issue 748)

  

我遇到了一个多实例任务的新问题,当我们循环遍历的集合在循环后的任何时候都为空时,它们会因PvmException(“已经进行过渡”)而失败。

您应尝试在循环之前创建一个新的不可修改列表。检查原始列表不为空后,创建一个新列表进行循环。