Usertask Inserted twice

Hello,

When reaching a userTask in my bpmn, it seems that 2 tasks are inserted for 1 execution. It’s wierd because they are inserted at the same time in a bulkinsert.

 <process id="export" name="Export" >
    <startEvent id="startEvent"/>
    <sequenceFlow sourceRef="startEvent" targetRef="beginning"/>

    <!-- START -->
    <scriptTask id="beginning" name="beginning" scriptFormat="groovy">
        <script>
            def profile = execution.getVariable("profile")
            def jobId = execution.getVariable("jobId")
            org.slf4j.LoggerFactory.getLogger("beginning").info("job:$jobId ->  $profile")
        </script>
    </scriptTask>

    <sequenceFlow sourceRef="beginning" targetRef="captureTask"/>
    <!-- CAPTURE -->
    <serviceTask id="captureTask" name="Capture pivot task" flowable:delegateExpression="${captureTaskService}"/> 
    <sequenceFlow sourceRef="captureTask" targetRef="exportTask"/>

    <!-- EXPORT -->
    <serviceTask id="exportTask" name="Export pivot task" 
            flowable:triggerable="true" flowable:async="true"
            flowable:delegateExpression="${exportTaskService}"/>
    <sequenceFlow sourceRef="exportTask" targetRef="qcTask"/>        

    <!-- QC -->
    <userTask id="qcTask" name="QC task" flowable:candidateGroups="CTN">
    </userTask>
     <sequenceFlow sourceRef="qcTask" targetRef="closeTask"/> 

The job logs:

DEBUG org.flowable.engine.impl.persistence.entity.ActivityInstanceEntityImpl.bulkInsertActivityInstance - ==>  Preparing: insert into ACT_RU_ACTINST ( ID_, REV_, PROC_DEF_ID_, PROC_INST_ID_, EXECUTION_ID_, ACT_ID_, TASK_ID_, CALL_PROC_INST_ID_, ACT_NAME_, ACT_TYPE_, ASSIGNEE_, START_TIME_, END_TIME_, DURATION_, DELETE_REASON_, TENANT_ID_ ) values (?, 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) , (?, 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) 

DEBUG org.flowable.engine.impl.persistence.entity.ActivityInstanceEntityImpl.bulkInsertActivityInstance - ==> Parameters: 20(String), export:1:6(String), 7(String), 10(String), _flow_exportTask__qcTask(String), null, null, null, sequenceFlow(String), null, 2019-10-29 14:49:24.85(Timestamp), 2019-10-29 14:49:24.85(Timestamp), 0(Long), null, (String), 21(String), export:1:6(String), 7(String), 10(String), qcTask(String), 24(String), null, QC task(String), userTask(String), null, 2019-10-29 14:49:24.851(Timestamp), null, null, null, (String)
DEBUG org.flowable.engine.impl.persistence.entity.ActivityInstanceEntityImpl.bulkInsertActivityInstance - <== Updates: 2

Then when I try to complete thoses tasks:
Caused by: org.flowable.common.engine.api.FlowableException: UserTask should not be signalled before complete

I haven’t ever seen this issue, but here are some questions to get people thinking:

  • What version of Flowable are you using?
  • Is this consistent, does it happen every time?
  • The task immediately prior is an async triggerable service task, can you share what exportTaskService does, the content exportTaskService's trigger method, and the code you’re using to trigger exportTask's completion? If not, the gist of what is going on there may be helpful.

Will

Thanks for the reply!

  • I am using 6.4.2
  • It’s consistent
  • Export call an external webservice and then a rabbitmq listener call
    def execution = runtimeService.createExecutionQuery()
    .processInstanceId(job.process.processId).activityId(“exportTask”).singleResult()
    runtimeService.triggerAsync(execution.getId())
  • next, we see that 2 user tasks are created

That seems like it should work. Is there a possibility that there is more than one message triggering the rabbitmq listener or that the same message is getting read on more than one node?

Will

Thanks Will, I figured it out.

I was adding a leave() in the trigger of the Task. I did that because in some code example it was shown to do it this way.

Anyways. once removed, everything works fine.