Execution has not subscribed to a signal event with name

Servus,

when I try to cancel a user task by means of a signal boundary event I get the error message "Execution has not subscribed to a signal event with name ‘sigCancel’. Below is the test process.

Is it possible at all to interrupt a user task with a boundary signal event?

In a unit test (the one provided by Camunda test-project) I do the following after starting the process:

    // Given we create a new process instance
    ProcessInstance processInstance = runtimeService().startProcessInstanceByKey("testProcess");
    // Then it should be active
    assertThat(processInstance).isActive();
    // And it should be the only instance
    assertThat(processInstanceQuery().count()).isEqualTo(1);
    // And there should exist just a single task within that process instance
    assertThat(task(processInstance)).isNotNull();

    final String currentActivityId = rule.getRuntimeService().getActiveActivityIds(processInstance.getId()).get(0);
    Assertions.assertThat(currentActivityId).isEqualTo("utTest");

    // cancel task
    rule.getRuntimeService().signalEventReceived("sigCancel", processInstance.getId());

testProcess.bpmn (3.8 KB)

Thanks in advance,
Best regards,
Torsten

Hi @xman-berlin,

to deliver a signal to a single execution then you need first to query for signal event subscription to get the correct execution Id.

Below is an example of a REST call to query for signal event subscription
/event-subscription?eventName=sigCancel&eventType=signal&processInstanceId=XXX

then you can use the executionId from the result in your throwing signal call
rule.getRuntimeService().signalEventReceived("sigCancel", <EXECUTION_ID>);

activity A is a scope activity. Due to the boundary event, it defines a context in which events can be received. This context is valid for the lifetime of the activity instance. It therefore requires an extra execution.

1 Like

Hi @hassang ,

this helped.

        // cancel task
        final List<Execution> executions = runtimeService().createExecutionQuery().
                processInstanceId(processInstance.getId()).
                signalEventSubscriptionName("sigCancel").list();
        assertThat(executions).isNotEmpty();
        runtimeService().signalEventReceived("sigCancel", executions.get(0).getId());

Thanks,
Torsten