SignalBoundaryEvent on ServiceTask

Hi,

I have tried to use a boundaryEvent on UserTask. It does work properly :

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
targetNamespace="test">
    <signal id="cancel_signal" name="cancel" />
    <process id="process_simple_boundary_event_signal_step" isExecutable="true">
        <ioSpecification>
            <dataInput id="release_version_key" name="release_version_key" />
            <inputSet name="mandatory">
                <dataInputRefs>release_version_key</dataInputRefs>
            </inputSet>
            <outputSet />
        </ioSpecification>
        <startEvent id="StartEvent_1">
            <outgoing>Flow_0s5f35d</outgoing>
        </startEvent>
        <endEvent id="Event_05rkhyq" name="end1">
            <incoming>Flow_1ko4giq</incoming>
        </endEvent>
        <sequenceFlow id="Flow_0s5f35d" sourceRef="StartEvent_1" targetRef="Activity_0m23tfp" />
        <sequenceFlow id="Flow_13nit2a" sourceRef="Activity_0m23tfp" targetRef="Activity_12659fg" />
        <userTask id="Activity_0m23tfp" name="userTask">
            <incoming>Flow_0s5f35d</incoming>
            <outgoing>Flow_13nit2a</outgoing>
        </userTask>
        <boundaryEvent id="Event_05ghl5e" attachedToRef="Activity_0m23tfp">
            <outgoing>Flow_100uub0</outgoing>
            <signalEventDefinition id="SignalEventDefinition_1w75ox6" signalRef="cancel_signal" />
        </boundaryEvent>
        <endEvent id="Event_0wlix86" name="end2">
            <incoming>Flow_0tvqz3v</incoming>
        </endEvent>
        <sequenceFlow id="Flow_100uub0" sourceRef="Event_05ghl5e" targetRef="Activity_0vo281u" />
        <sequenceFlow id="Flow_1ko4giq" sourceRef="Activity_12659fg" targetRef="Event_05rkhyq" />
        <userTask id="Activity_12659fg" name="userTask2">
            <incoming>Flow_13nit2a</incoming>
            <outgoing>Flow_1ko4giq</outgoing>
        </userTask>
        <sequenceFlow id="Flow_0tvqz3v" sourceRef="Activity_0vo281u" targetRef="Event_0wlix86" />
        <userTask id="Activity_0vo281u" name="userTask3">
            <incoming>Flow_100uub0</incoming>
            <outgoing>Flow_0tvqz3v</outgoing>
        </userTask>
    </process>
    <bpmndi:BPMNDiagram id="BPMNDiagram_1">
        <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="process_simple_boundary_event_signal_step">
            <bpmndi:BPMNEdge id="Flow_100uub0_di" bpmnElement="Flow_100uub0">
                <di:waypoint x="460" y="308" />
                <di:waypoint x="460" y="330" />
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge id="Flow_13nit2a_di" bpmnElement="Flow_13nit2a">
                <di:waypoint x="510" y="250" />
                <di:waypoint x="580" y="250" />
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge id="Flow_0s5f35d_di" bpmnElement="Flow_0s5f35d">
                <di:waypoint x="348" y="250" />
                <di:waypoint x="410" y="250" />
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge id="Flow_1ko4giq_di" bpmnElement="Flow_1ko4giq">
                <di:waypoint x="680" y="250" />
                <di:waypoint x="722" y="250" />
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge id="Flow_0tvqz3v_di" bpmnElement="Flow_0tvqz3v">
                <di:waypoint x="550" y="370" />
                <di:waypoint x="592" y="370" />
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
                <dc:Bounds x="312" y="232" width="36" height="36" />
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape id="Activity_0ulkunc_di" bpmnElement="Activity_0m23tfp">
                <dc:Bounds x="410" y="210" width="100" height="80" />
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape id="Event_05rkhyq_di" bpmnElement="Event_05rkhyq">
                <dc:Bounds x="722" y="232" width="36" height="36" />
                <bpmndi:BPMNLabel>
                    <dc:Bounds x="728" y="275" width="25" height="14" />
                </bpmndi:BPMNLabel>
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape id="Activity_0v3wxk0_di" bpmnElement="Activity_12659fg">
                <dc:Bounds x="580" y="210" width="100" height="80" />
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape id="Event_0wlix86_di" bpmnElement="Event_0wlix86">
                <dc:Bounds x="592" y="352" width="36" height="36" />
                <bpmndi:BPMNLabel>
                    <dc:Bounds x="598" y="395" width="25" height="14" />
                </bpmndi:BPMNLabel>
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape id="Activity_019v7sk_di" bpmnElement="Activity_0vo281u">
                <dc:Bounds x="450" y="330" width="100" height="80" />
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape id="Event_1hfcnkw_di" bpmnElement="Event_05ghl5e">
                <dc:Bounds x="442" y="272" width="36" height="36" />
            </bpmndi:BPMNShape>
        </bpmndi:BPMNPlane>
    </bpmndi:BPMNDiagram>
</definitions>

I replaced the userTask by a ServiceTask and the signal is never catched :

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:flowable="http://flowable.org/bpmn" 
targetNamespace="test">

    <signal id="cancel_signal" name="cancel" />
    <process id="process_simple_boundary_event_signal_step" isExecutable="true">
        <ioSpecification>
            <dataInput id="release_version_key" name="release_version_key" />
            <inputSet name="mandatory">
                <dataInputRefs>release_version_key</dataInputRefs>
            </inputSet>
            <outputSet />
        </ioSpecification>
        <startEvent id="StartEvent_1">
            <outgoing>Flow_0s5f35d</outgoing>
        </startEvent>
        <endEvent id="Event_05rkhyq" name="end1">
            <incoming>Flow_1ko4giq</incoming>
        </endEvent>
        <sequenceFlow id="Flow_0s5f35d" sourceRef="StartEvent_1" targetRef="Activity_0m23tfp" />
        <sequenceFlow id="Flow_13nit2a" sourceRef="Activity_0m23tfp" targetRef="Activity_12659fg" />
        <serviceTask id="Activity_0m23tfp" name="serviceTask" flowable:async="true" flowable:delegateExpression="${fake_long_running}">
            <incoming>Flow_0s5f35d</incoming>
            <outgoing>Flow_13nit2a</outgoing>
        </serviceTask>
        <boundaryEvent id="Event_05ghl5e" attachedToRef="Activity_0m23tfp">
            <outgoing>Flow_100uub0</outgoing>
            <signalEventDefinition id="SignalEventDefinition_1w75ox6" signalRef="cancel_signal" />
        </boundaryEvent>
        <endEvent id="Event_0wlix86" name="end2">
            <incoming>Flow_0tvqz3v</incoming>
        </endEvent>
        <sequenceFlow id="Flow_100uub0" sourceRef="Event_05ghl5e" targetRef="Activity_0vo281u" />
        <sequenceFlow id="Flow_1ko4giq" sourceRef="Activity_12659fg" targetRef="Event_05rkhyq" />
        <userTask id="Activity_12659fg" name="userTask2">
            <incoming>Flow_13nit2a</incoming>
            <outgoing>Flow_1ko4giq</outgoing>
        </userTask>
        <sequenceFlow id="Flow_0tvqz3v" sourceRef="Activity_0vo281u" targetRef="Event_0wlix86" />
        <userTask id="Activity_0vo281u" name="userTask3">
            <incoming>Flow_100uub0</incoming>
            <outgoing>Flow_0tvqz3v</outgoing>
        </userTask>
    </process>
    <bpmndi:BPMNDiagram id="BPMNDiagram_1">
        <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="process_simple_boundary_event_signal_step">
            <bpmndi:BPMNEdge id="Flow_100uub0_di" bpmnElement="Flow_100uub0">
                <di:waypoint x="460" y="308" />
                <di:waypoint x="460" y="330" />
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge id="Flow_13nit2a_di" bpmnElement="Flow_13nit2a">
                <di:waypoint x="510" y="250" />
                <di:waypoint x="580" y="250" />
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge id="Flow_0s5f35d_di" bpmnElement="Flow_0s5f35d">
                <di:waypoint x="348" y="250" />
                <di:waypoint x="410" y="250" />
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge id="Flow_1ko4giq_di" bpmnElement="Flow_1ko4giq">
                <di:waypoint x="680" y="250" />
                <di:waypoint x="722" y="250" />
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge id="Flow_0tvqz3v_di" bpmnElement="Flow_0tvqz3v">
                <di:waypoint x="550" y="370" />
                <di:waypoint x="592" y="370" />
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
                <dc:Bounds x="312" y="232" width="36" height="36" />
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape id="Activity_0ulkunc_di" bpmnElement="Activity_0m23tfp">
                <dc:Bounds x="410" y="210" width="100" height="80" />
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape id="Event_05rkhyq_di" bpmnElement="Event_05rkhyq">
                <dc:Bounds x="722" y="232" width="36" height="36" />
                <bpmndi:BPMNLabel>
                    <dc:Bounds x="728" y="275" width="25" height="14" />
                </bpmndi:BPMNLabel>
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape id="Activity_0v3wxk0_di" bpmnElement="Activity_12659fg">
                <dc:Bounds x="580" y="210" width="100" height="80" />
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape id="Event_0wlix86_di" bpmnElement="Event_0wlix86">
                <dc:Bounds x="592" y="352" width="36" height="36" />
                <bpmndi:BPMNLabel>
                    <dc:Bounds x="598" y="395" width="25" height="14" />
                </bpmndi:BPMNLabel>
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape id="Activity_019v7sk_di" bpmnElement="Activity_0vo281u">
                <dc:Bounds x="450" y="330" width="100" height="80" />
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape id="Event_1hfcnkw_di" bpmnElement="Event_05ghl5e">
                <dc:Bounds x="442" y="272" width="36" height="36" />
            </bpmndi:BPMNShape>
        </bpmndi:BPMNPlane>
    </bpmndi:BPMNDiagram>
</definitions>

In attachment you have the two flows.

Regards,

Loic Seguin

Boundary events on automatic service tasks won’t work - they only work on wait states.
Once a service task is started, it cannot be stopped - checking continuously for boundary events firing would be bad for performance.