Issue Getting Signal Boundary Event to Trigger

Description

Heading 1

Heading 2

Col A1

Col A2

UPDATE 2: I fixed the hyperlinks so they don't redirect to www.example.com, apologies for the mistake on my part!

UPDATE: I made a new account on the Activiti Forum and my topic was finally posted, so it's probably better to address the issue on the forum now. The link to the topic is here: https://forums.activiti.org/content/issue-getting-signal-boundary-event-trigger
Please take a look at it and thank you!

My apologies for bringing up this issue here as I realize it's likely more of a conceptual issue than a bug, but on the Activiti forum my newly created topic would not post for some reason. As this is crucial to my (and probably others') workflows, I thought I'd directly ask the experts here on JIRA. 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:

http://i.imgur.com/0sEVmNy.png

The corresponding XML source code for the diagram follows:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" 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" xmlns:tns="http://www.activiti.org/test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:yaoqiang="http://bpmn.sourceforge.net" exporter="" exporterVersion="" expressionLanguage="http://www.w3.org/1999/XPath" id="m1452892595912" name="" targetNamespace="http://www.activiti.org/test" typeLanguage="http://www.w3.org/2001/XMLSchema" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL http://bpmn.sourceforge.net/schemas/BPMN20.xsd">
<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">
<incoming>startFlow</incoming>
<outgoing>normalEndFlow</outgoing>
</userTask>
<boundaryEvent attachedToRef="userTask" cancelActivity="true" id="cancelTask" name="Cancel Task" parallelMultiple="false">
<outgoing>cancelFlow</outgoing>
<outputSet/>
<signalEventDefinition id="cancelTaskEvent" signalRef="cancelSignal"/>
</boundaryEvent>
<startEvent id="startEvent" isInterrupting="true" name="Start Event" parallelMultiple="false">
<outgoing>startFlow</outgoing>
<outputSet/>
</startEvent>
<sequenceFlow id="startFlow" sourceRef="startEvent" targetRef="userTask"/>
<endEvent id="normalEndEvent" name="End Event">
<incoming>normalEndFlow</incoming>
<inputSet/>
</endEvent>
<sequenceFlow id="cancelFlow" sourceRef="cancelTask" targetRef="cancelEndEvent"/>
<endEvent id="cancelEndEvent" name="End Event">
<incoming>cancelFlow</incoming>
<inputSet/>
</endEvent>
<sequenceFlow id="normalEndFlow" sourceRef="userTask" targetRef="normalEndEvent"/>
</process>
</definitions>

The code for the unit test follows:

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

runtimeService.signalEventReceived("Cancel Signal",
runtimeService.createExecutionQuery()
.signalEventSubscriptionName("Cancel Signal")
.singleResult()
.getId());

println(historyService.createHistoricActivityInstanceQuery()
.unfinished()
.list()
.map(h => h.getActivityName)
.mkString("\n"));

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!

Environment

OSX, Spring hello

Activity

Show:
Vlad Stan
December 8, 2016, 8:42 AM

Hi Ben,

I have managed to reproduce your issue. A similar scenario is covered in the unit test:

The only difference between your scenario and the unit test is that the unit test has a different scope for the Signal Event.
Unit Test:

Your test:

If you change the activiti:scope to global, your test will pass.

Vlad Stan
December 8, 2016, 8:51 AM
Edited

The scope for signal events is described here:

My assumption is that the processInstance scope makes sense when the Signal Event is thrown from inside the process (a SignalThrowingEvent).

When the signal is "thrown" from the API then the global scope should be used. If you specify the executionId, like you did:

Then only that executionId is notified (not all executions).

I have created a unit test with two processes to check that only one of them catches the event when an executionId is specified. You can find the test here:
https://github.com/motorina0/activiti/blob/master/tests/act-4205/src/test/java/org/activiti/demo/MyUnitTest.java

Johnathan James
February 13, 2017, 5:46 PM

Is the verdict that this is not an issue? Or, should it at least be resolved as WONT FIX?

Assignee

Joram Barrez

Reporter

Ben Zheng

Labels

None

Components

Affects versions

Priority

Highest
Configure