Activiti流程中的任务加倍

时间:2018-08-19 08:14:09

标签: apache-camel activiti apache-servicemix

我已经在生产环境中运行了一个Activiti代码(在Servicemix上使用Camel运行Activiti 5.19),并且遇到了一些特殊的问题:有时我在执行过程中遇到了任务加倍的情况(其中一个甚至是三倍)。似乎没有明确的模式。如果由于某种原因任何JavaScript调用服务两次关闭同一任务,我测试过的代码将引发异常。

因为任务是运行中执行的一部分,所以无法完成加倍的任务(导致“在完成前不发出UserTask信号”异常)或删除任务。

我无法弄清楚是什么原因会导致这种后果,以及如何摆脱多余的任务才能完成受损的过程。

是否可以仅删除act_ru_task中的更高记录(具有最高任务ID)?

有人可以帮忙吗?

<?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">
    <collaboration id="Collaboration">
        <participant id="pool1" name="Pool" processRef="process_pool1"></participant>
    </collaboration>
     <process id="new_marketing" name="marketing" isExecutable="true" activiti:candidateStarterGroups="marketing,task_manager">
    <laneSet id="laneSet_new_marketing">
      <lane id="lane1" name="marketing">
        <flowNodeRef>usertask1</flowNodeRef>
        <flowNodeRef>startevent1</flowNodeRef>
        <flowNodeRef>exclusivegateway1</flowNodeRef>
        <flowNodeRef>usertask2</flowNodeRef>
        <flowNodeRef>usertask3</flowNodeRef>
        <flowNodeRef>usertask4</flowNodeRef>
        <flowNodeRef>endevent1</flowNodeRef>
        <flowNodeRef>exclusivegateway2</flowNodeRef>
        <flowNodeRef>exclusivegateway3</flowNodeRef>
        <flowNodeRef>usertask5</flowNodeRef>
        <flowNodeRef>usertask6</flowNodeRef>
        <flowNodeRef>endevent2</flowNodeRef>
      </lane>
    </laneSet>

    <startEvent id="startevent1" name="Start"></startEvent>

    <userTask id="usertask1" name="Status_0" activiti:assignee="${employeeName}" activiti:candidateGroups="marketing" activiti:dueDate="${dueDate}">
      <extensionElements>
        <activiti:formProperty id="actionsForm" name="actions" type="enum" writable="false">
          <activiti:value id="cancel" name="cancel"></activiti:value>
          <activiti:value id="accepted" name="accepted"></activiti:value>
          <activiti:value id="wait" name="wait"></activiti:value>
        </activiti:formProperty>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow12" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>

    <exclusiveGateway id="exclusivegateway1" name="Exclusive Gateway"></exclusiveGateway>
    <sequenceFlow id="flow1" sourceRef="usertask1" targetRef="exclusivegateway1"></sequenceFlow>
    <userTask id="usertask2" name="Status_10" activiti:assignee="${employeeName}">
        <extensionElements>
            <activiti:formProperty id="actionsForm" name="actions" type="enum" writable="false">
              <activiti:value id="cancel" name="cancel"></activiti:value>
              <activiti:value id="proceed" name="proceed"></activiti:value>
              <activiti:value id="application" name="application"></activiti:value>
              <activiti:value id="accepted" name="accepted"></activiti:value>
              <activiti:value id="wait" name="wait"></activiti:value>
            </activiti:formProperty>
        </extensionElements>
    </userTask>
    <sequenceFlow id="flow2" sourceRef="exclusivegateway1" targetRef="usertask2">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${action == 'accepted'}]]></conditionExpression>
    </sequenceFlow>
    <userTask id="usertask3" name="Status_1" activiti:assignee="${employeeName}" activiti:dueDate="${dueDate}"></userTask>
    <sequenceFlow id="flow3" name="Wait" sourceRef="exclusivegateway1" targetRef="usertask3">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${action == 'wait'}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow4" sourceRef="usertask3" targetRef="usertask1"></sequenceFlow>
    <userTask id="usertask4" name="Status_1000" activiti:assignee="${employeeName}"></userTask>
    <sequenceFlow id="flow5" name="GiveUp" sourceRef="exclusivegateway1" targetRef="usertask4">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${action == 'cancel'}]]></conditionExpression>
    </sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow6" sourceRef="usertask4" targetRef="endevent1"></sequenceFlow>
    <exclusiveGateway id="exclusivegateway2" name="Exclusive Gateway"></exclusiveGateway>
    <sequenceFlow id="flow7" sourceRef="usertask2" targetRef="exclusivegateway2"></sequenceFlow>

    <endEvent id="endevent2" name="End"></endEvent>

    <sequenceFlow id="flow10" sourceRef="exclusivegateway2" targetRef="usertask2">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${action == 'wait'}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow11" name="GiveUp" sourceRef="exclusivegateway2" targetRef="usertask4">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${action == 'cancel'}]]></conditionExpression>
    </sequenceFlow>


    <sequenceFlow id="flow8" sourceRef="exclusivegateway2" targetRef="usertask5">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${action == 'application'}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow13" sourceRef="exclusivegateway2" targetRef="usertask6">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${action == 'proceed' || action == 'accepted'}]]></conditionExpression>
    </sequenceFlow>
    <userTask id="usertask5" name="Status_50" activiti:assignee="${employeeName}">
        <extensionElements>
            <activiti:formProperty id="actionsForm" name="actions" type="enum" writable="false">
              <activiti:value id="cancel" name="cancel"></activiti:value>
              <activiti:value id="accepted" name="accepted"></activiti:value>
            </activiti:formProperty>
        </extensionElements>
    </userTask>

    <sequenceFlow id="flow14" sourceRef="usertask5" targetRef="exclusivegateway3"></sequenceFlow>

    <exclusiveGateway id="exclusivegateway3" name="Exclusive Gateway"></exclusiveGateway>

    <sequenceFlow id="flow15" sourceRef="exclusivegateway3" targetRef="usertask6">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${action == 'accepted'}]]></conditionExpression>
    </sequenceFlow>

    <userTask id="usertask6" name="Status_90" activiti:assignee="${employeeName}"></userTask>

    <sequenceFlow id="flow17" sourceRef="usertask6" targetRef="endevent2">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${action == 'accepted'}]]></conditionExpression>
    </sequenceFlow>

    <sequenceFlow id="flow16" sourceRef="exclusivegateway3" targetRef="usertask4">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${action == 'cancel'}]]></conditionExpression>
    </sequenceFlow>

  </process>
</definitions>

使用以下查询在Activiti数据库中检查了问题:

select * from act_ru_task t0 where t0.execution_id_ in (select id_ from act_ru_execution t1 where (select count(*) from act_ru_task t2 where t1.id_ = t2.execution_id_) > 1);

查询显示了30种类似情况,其中3种以下(用户登录被自动删除):

     id_    | rev_ | execution_id_ | proc_inst_id_ |     proc_def_id_     |    name_    | parent_task_id_ | description_ | task_def_key_ | owner_ |  assignee_   |delegation_   | priority_ |      create_time_       |
     118399 |    1 | 118373        | 118373        | new_marketing:3:5004 | Status_50   |                 |              | usertask5     |        | auser        |              |        50 | 2017-08-08 08:46:28.771 |
     118396 |    1 | 118373        | 118373        | new_marketing:3:5004 | Status_50   |                 |              | usertask5     |        | auser        |              |        50 | 2017-08-08 08:46:28.769 |
     634792 |    1 | 453636        | 453636        | new_marketing:3:5004 | Status_1000 |                 |              | usertask4     |        | buser        |              |        50 | 2018-04-04 09:49:13.853 |
     634791 |    1 | 453636        | 453636        | new_marketing:3:5004 | Status_1000 |                 |              | usertask4     |        | buser        |              |        50 | 2018-04-04 09:49:13.853 |
     527864 |    1 | 527837        | 527837        | new_marketing:3:5004 | Status_90   |                 |              | usertask6     |        | cuser        |              |        50 | 2018-02-01 16:06:56.089 |
     527867 |    1 | 527837        | 527837        | new_marketing:3:5004 | Status_90   |                 |              | usertask6     |        | cuser        |              |        50 | 2018-02-01 16:06:56.092 |

0 个答案:

没有答案