AnsweredAssumed Answered

Issue Getting Signal Boundary Event to Trigger

Question asked by zhengzizhan on Aug 7, 2016
Hi all,

I've been working on a project using Activiti 6.0.0.Beta2, and I've run into an issue with signal boundary events attached to user tasks not triggering. I've searched and made adjustments to my code based on what other people on this forum have said worked for them, but unfortunately I'm still having the same issue. I've created a unit test in Java along with a corresponding BPMN diagram which I've included below to illustrate the problem. The BPMN diagram is as follows:


The corresponding XML source code for the diagram follows:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns="" xmlns:activiti="" xmlns:bpmndi="" xmlns:omgdc="" xmlns:omgdi="" xmlns:tns="" xmlns:xsd="" xmlns:xsi="" xmlns:yaoqiang="" exporter="" exporterVersion="" expressionLanguage="" id="m1452892595912" name="" targetNamespace="" typeLanguage="" xsi:schemaLocation="">
  <signal activiti:scope="processInstance" id="cancelSignal" name="Cancel Signal"/>
  <process id="signalTestProcess" isClosed="false" isExecutable="true" processType="None">
    <userTask completionQuantity="1" id="userTask" implementation="##unspecified" isForCompensation="false" name="User Task" startQuantity="1">
    <boundaryEvent attachedToRef="userTask" cancelActivity="true" id="cancelTask" name="Cancel Task" parallelMultiple="false">
      <signalEventDefinition id="cancelTaskEvent" signalRef="cancelSignal"/>
    <startEvent id="startEvent" isInterrupting="true" name="Start Event" parallelMultiple="false">
    <sequenceFlow id="startFlow" sourceRef="startEvent" targetRef="userTask"/>
    <endEvent id="normalEndEvent" name="End Event">
    <sequenceFlow id="cancelFlow" sourceRef="cancelTask" targetRef="cancelEndEvent"/>
    <endEvent id="cancelEndEvent" name="End Event">
    <sequenceFlow id="normalEndFlow" sourceRef="userTask" targetRef="normalEndEvent"/>

The code for the unit test follows:


    Assert.assertEquals(1, runtimeService.createExecutionQuery().signalEventSubscriptionName("Cancel Signal").list().size());

    runtimeService.signalEventReceived("Cancel Signal",
                    .signalEventSubscriptionName("Cancel Signal")

                          .map(h => h.getActivityName)

    Assert.assertEquals(0, taskService.createTaskQuery().count());

When I run the unit test I get the error "java.lang.AssertionError: Expected :0 Actual :1" corresponding to the assertion in the last line. Also, the println function prints "User Task". These results seem to imply that after signalEventReceived is run, the execution remains at User Task instead of going down the signal boundary event flow. In terms of common issues with signal events that I've addressed in my code, the signal name (and not the signal id) is passed to signalEventReceived and the cancelActivity attribute for the signal boundary event is set to true. Also, as the first assertion passes successfully, I'm pretty certain that the correct execution id is being passed to signalEventReceived. If anyone could provide insight on why the execution still refuses to go down the signal boundary event flow I'd greatly appreciate it. Thanks!