SignalEvent Handling in Flowable vs Activiti

Hi there,

has the signalEvant handling been changed in flowable 6?

the blow snippet works in activiti 5.22.0 but produces an error in flowable 6.0.1
org.flowable.engine.common.api.FlowableException: Execution '6' has not subscribed to a signal event with name 'signal'.

public class SignalTest {
	@Test
	public void testSignal() {
		ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();

		TaskService taskService = processEngine.getTaskService();
		RepositoryService repositoryService = processEngine.getRepositoryService();
		RuntimeService runtimeService = processEngine.getRuntimeService();

		repositoryService.createDeployment().name("simple").addClasspathResource("processes/simple.bpmn").deploy();
		
		runtimeService.startProcessInstanceByKey("eventProcess");
	    
		Task t = taskService.createTaskQuery().taskDefinitionKey("userTask").singleResult();
		runtimeService.signalEventReceived("signal", t.getExecutionId());
				
		assertTrue(runtimeService.createProcessInstanceQuery().list().size() == 0);	    
	    
	}
}



<?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" xmlns:flowable="http://flowable.org/bpmn" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="Examples">
  <signal id="signal" name="signal"></signal>
  <process id="eventProcess" isExecutable="true">
    <startEvent id="start"></startEvent>
    <userTask id="userTask" name="User Task"></userTask>
    <boundaryEvent id="boundaryEvent" name="Boundary event" attachedToRef="userTask" cancelActivity="true">
      <signalEventDefinition signalRef="signal"></signalEventDefinition>
    </boundaryEvent>
    <sequenceFlow id="flow4" sourceRef="userTask" targetRef="end"></sequenceFlow>
    <endEvent id="end"></endEvent>
    <scriptTask id="scripttask1" name="Script Task" scriptFormat="groovy" activiti:autoStoreVariables="false">
      <script><![CDATA[out:println "Signal Received";]]></script>
    </scriptTask>
    <sequenceFlow id="flow7" sourceRef="boundaryEvent" targetRef="scripttask1"></sequenceFlow>
    <sequenceFlow id="flow8" sourceRef="scripttask1" targetRef="end"></sequenceFlow>
    <sequenceFlow id="flow9" sourceRef="start" targetRef="userTask"></sequenceFlow>
  </process>
</definitions>

Hi,

The execution id of the signal event can be different than in Activiti 5.22.0. In Flowable 6 more executions are created so scoping is better handled and the execution tree is more consistent. You could query for the correct execution with the ExecutionQuery signalEventSubscriptionName method.

Best regards,

Tijs

Hi Tijs,

thanks for the reply. I see that ExecutionQuery returns a execution, but this is now the boundary event.
Now I have to run the query and navigate to the parent’s execution Id, first.

Previously, in activiti, I used to use the execution Id of the ScopeExecution, which was the UserTask in my example, directly. I liked the old style as this made it quite easy to signal a UserTask, i.e. to abort it, with just one TaskQuery.

best
Holger