cancel
Showing results for 
Search instead for 
Did you mean: 

Active events on completed tasks

leonhardtdavid
Champ in-the-making
Champ in-the-making
Hi!!

I'm new in Activiti, but I'm having a problem on a single task in my process.

I can't finish a process instance because I have active events belonging to finished execution.
I'm using activiti 5.11 and the activiti designer.


Thank you very much,
David.
13 REPLIES 13

jbarrez
Star Contributor
Star Contributor
'active events' … i have no clue what you mean with that.
Could you describe your problem a bit better?

leonhardtdavid
Champ in-the-making
Champ in-the-making
Sorry.

I have two rows in ACT_RU_EVENT_SUBSCR with an execution id and that id is not in ACT_RU_EXECUTION or ACT_RU_TASK.

Thanks.

frederikherema1
Star Contributor
Star Contributor
What's the error stack trace?

leonhardtdavid
Champ in-the-making
Champ in-the-making
This is the link to the error stack trace:

http://pastebin.com/Dy9e5R6R

jbarrez
Star Contributor
Star Contributor
Really strange issue … can't directly see how it could be caused.
Is there any way you can create a reproducable unit test?

leonhardtdavid
Champ in-the-making
Champ in-the-making
It is quite difficult to do, since I've seen happening in a particular task and not always.

jbarrez
Star Contributor
Star Contributor
well, can't you use that particular task in a unit test 😉

Otherwise it's pretty hard to validate for us.

leonhardtdavid
Champ in-the-making
Champ in-the-making
Hello again,.

I understood when I have the problem, so there is de unit test (I used a boundary event signal, is the same for a timer):

I use this template: https://github.com/Activiti/activiti-unit-test-template


Process:
<code>
<?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:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="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">
  <signal id="signal" name="Signal"></signal>
  <process id="my-process" name="My process" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <userTask id="usertask1" name="User Task 1"></userTask>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow2" sourceRef="usertask1" targetRef="endevent1"></sequenceFlow>
    <boundaryEvent id="boundarysignal1" name="Signal" attachedToRef="usertask1" cancelActivity="false">
      <signalEventDefinition signalRef="signal"></signalEventDefinition>
    </boundaryEvent>
    <userTask id="usertask2" name="User Task 2"></userTask>
    <sequenceFlow id="flow3" sourceRef="usertask1" targetRef="usertask2"></sequenceFlow>
    <endEvent id="endevent2" name="End"></endEvent>
    <sequenceFlow id="flow4" sourceRef="usertask2" targetRef="endevent2"></sequenceFlow>
    <subProcess id="subprocess1" name="Sub Process">
      <startEvent id="startevent2" name="Start"></startEvent>
      <userTask id="usertask3" name="User Task 3"></userTask>
      <sequenceFlow id="flow6" sourceRef="startevent2" targetRef="usertask3"></sequenceFlow>
      <endEvent id="endevent3" name="End"></endEvent>
      <sequenceFlow id="flow7" sourceRef="usertask3" targetRef="endevent3"></sequenceFlow>
    </subProcess>
    <sequenceFlow id="flow5" sourceRef="boundarysignal1" targetRef="subprocess1"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_my-process">
    <bpmndi:BPMNPlane bpmnElement="my-process" id="BPMNPlane_my-process">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="120.0" y="130.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
        <omgdc:Bounds height="55.0" width="105.0" x="200.0" y="120.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="boundarysignal1" id="BPMNShape_boundarysignal1">
        <omgdc:Bounds height="30.0" width="30.0" x="275.0" y="160.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="360.0" y="130.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask2" id="BPMNShape_usertask2">
        <omgdc:Bounds height="55.0" width="105.0" x="360.0" y="120.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent2" id="BPMNShape_endevent2">
        <omgdc:Bounds height="35.0" width="35.0" x="520.0" y="130.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="subprocess1" id="BPMNShape_subprocess1">
        <omgdc:Bounds height="101.0" width="291.0" x="144.0" y="240.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="startevent2" id="BPMNShape_startevent2">
        <omgdc:Bounds height="35.0" width="35.0" x="174.0" y="280.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask3" id="BPMNShape_usertask3">
        <omgdc:Bounds height="55.0" width="105.0" x="244.0" y="270.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent3" id="BPMNShape_endevent3">
        <omgdc:Bounds height="35.0" width="35.0" x="374.0" y="280.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="155.0" y="147.0"></omgdi:waypoint>
        <omgdi:waypoint x="200.0" y="147.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="305.0" y="147.0"></omgdi:waypoint>
        <omgdi:waypoint x="360.0" y="147.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="305.0" y="147.0"></omgdi:waypoint>
        <omgdi:waypoint x="360.0" y="147.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
        <omgdi:waypoint x="465.0" y="147.0"></omgdi:waypoint>
        <omgdi:waypoint x="520.0" y="147.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
        <omgdi:waypoint x="209.0" y="297.0"></omgdi:waypoint>
        <omgdi:waypoint x="244.0" y="297.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
        <omgdi:waypoint x="349.0" y="297.0"></omgdi:waypoint>
        <omgdi:waypoint x="374.0" y="297.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
        <omgdi:waypoint x="290.0" y="190.0"></omgdi:waypoint>
        <omgdi:waypoint x="289.0" y="240.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>
</code>

Unit test:
<java>
package org.activiti;
import java.util.List;

import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.runtime.Execution;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.activiti.engine.test.ActivitiRule;
import org.activiti.engine.test.Deployment;
import org.junit.Rule;
import org.junit.Test;

import static org.junit.Assert.*;

public class MyUnitTest {

@Rule
public ActivitiRule activitiRule = new ActivitiRule();

@Test
@Deployment(resources = {"org/activiti/test/my-process.bpmn20.xml"})
public void test() {
  RuntimeService runtimeService = activitiRule.getRuntimeService();
  TaskService taskService = activitiRule.getTaskService();
 
  String signalName = "Signal";
 
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("my-process");
  assertNotNull(processInstance);
 
  runtimeService.signalEventReceived(signalName);
 
  Task task1 = taskService.createTaskQuery().taskName("User Task 1").singleResult();
 
  if (task1 != null) {
   taskService.complete(task1.getId());
  }
 
  List<Execution> signals = runtimeService.createExecutionQuery()
    .signalEventSubscriptionName(signalName)
    .list();
 
  assertTrue(signals.size() == 0);
}

}

</java>

Thank you.

jbarrez
Star Contributor
Star Contributor
Thanks, excellent unit test.

I tried your unit test (on 5.15-SNAPSHOT), however it only failes on

<code>
assertTrue(signals.size() == 0);
</code>

which is logical, since the signal is global and not process instance scoped (activiti:scope="processInstance").

So it seems your issue is fixed in a later version of Activiti.