AnsweredAssumed Answered

cancelActivity = true in boundary event does not cancel process flow

Question asked by kkdw on Jun 23, 2015
Latest reply on Jun 24, 2015 by martin.grofcik
Hi,
I am currently playing around with SignalBoundaryEvents. I have this simple BMPN model depicted here http://imgur.com/aPxAgJE and outlined in xml below:

<?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">
  <signal id="SystemSignal" name="System Signal"></signal>
  <process id="myProcessSignal" name="My process signal" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <subProcess id="subprocess1" name="Sub Process">
      <serviceTask id="servicetask2" name="Service Task2" activiti:async="true" activiti:exclusive="false" activiti:class="testDelegates.TestDelegate"></serviceTask>
      <startEvent id="startevent2" name="Start"></startEvent>
      <endEvent id="endevent1" name="End"></endEvent>
      <sequenceFlow id="flow1" sourceRef="startevent2" targetRef="servicetask2"></sequenceFlow>
      <sequenceFlow id="flow2" sourceRef="servicetask2" targetRef="endevent1"></sequenceFlow>
    </subProcess>
    <serviceTask id="servicetask1" name="Service Task1" activiti:async="true" activiti:exclusive="false" activiti:class="testDelegates.TestDelegate"></serviceTask>
    <serviceTask id="servicetask3" name="Service Task3" activiti:async="true" activiti:exclusive="false" activiti:class="testDelegates.TestDelegate"></serviceTask>
    <sequenceFlow id="flow4" sourceRef="startevent1" targetRef="servicetask1"></sequenceFlow>
    <sequenceFlow id="flow5" sourceRef="servicetask1" targetRef="subprocess1"></sequenceFlow>
    <serviceTask id="servicetask4" name="Service Task4" activiti:class="testDelegates.TestDelegateSignal"></serviceTask>
    <sequenceFlow id="flow9" sourceRef="subprocess1" targetRef="servicetask3"></sequenceFlow>
    <boundaryEvent id="systemSignalCatch" name="systemSignalCatch" attachedToRef="subprocess1" cancelActivity="true">
      <signalEventDefinition signalRef="SystemSignal"></signalEventDefinition>
    </boundaryEvent>
    <sequenceFlow id="flow10" sourceRef="systemSignalCatch" targetRef="servicetask4"></sequenceFlow>
    <sequenceFlow id="flow11" sourceRef="servicetask3" targetRef="servicetask1"></sequenceFlow>
    <endEvent id="terminateendevent1" name="TerminateEndEvent">
      <terminateEventDefinition></terminateEventDefinition>
    </endEvent>
    <sequenceFlow id="flow12" sourceRef="servicetask4" targetRef="terminateendevent1"></sequenceFlow>
  </process>


The whole thing will loop service task 1 -> service task 2 -> service task 3 until a signal is received in the sub process that contains service task 2 which will lead to a SignalBoundaryEvents and ultimately to the termination of the whole thing.

When i trigger the signal via

….
Execution exec = runtime.createExecutionQuery().signalEventSubscription("System Signal").singleResult();
if(exec != null){
  runtime.signalEventReceived("System Signal", exec.getId());
}


things go as planned, i.e., the SignalBoundaryEvent is triggerd and consecutively the service task connected it is triggered leading to a terminateEndEvent. Eventhough I have set cancelActivity in the Boundaryevent to true  the process resumes with the loop ultimately leading to a org.activiti.engine.ActivitiObjectNotFoundException , which is confirmed when looking at the output of an EventListener

<blockcode>
ACTIVITY_STARTED
[servicetask4]
ACTIVITY_COMPLETED
[servicetask4]
SEQUENCEFLOW_TAKEN
[terminateendevent1]
ACTIVITY_STARTED
[terminateendevent1]
ACTIVITY_COMPLETED
PROCESS_COMPLETED
ENTITY_DELETED            //<- should end here
ACTIVITY_COMPLETED
[servicetask2]                //<- However resumes with loop
SEQUENCEFLOW_TAKEN
[endevent1]
ACTIVITY_STARTED
[endevent1]
ACTIVITY_COMPLETED
ACTIVITY_COMPLETED
ENTITY_DELETED
[subprocess1]
SEQUENCEFLOW_TAKEN
[servicetask3]
ENTITY_CREATED
[servicetask3]
ENTITY_INITIALIZED
[servicetask3]
ENTITY_DELETED
[servicetask3]
JOB_EXECUTION_SUCCESS
[servicetask3]
JOB_EXECUTION_FAILURE  //<- exceptions out
</blockcode>

Any ideas / hints on what I am doing wrong would be highly appreciated (I am using activiti 5.17.0).

Thanks in advance,
Konrad
 

Outcomes