# How to implement activiti signal intermediate catch event

**URL:** <https://forum.flowable.org/t/how-to-implement-activiti-signal-intermediate-catch-event/10014>\
**Category:** Flowable Engine\
**Created:** [December 19, 2022, 1:54am UTC](https://forum.flowable.org/t/how-to-implement-activiti-signal-intermediate-catch-event/10014 "2022-12-19T01:54:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kdevineni](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/kdevineni/32/35_2.png) [@kdevineni](https://forum.flowable.org/u/kdevineni)\
**Post date:** [December 19, 2022, 1:54am UTC](https://forum.flowable.org/t/how-to-implement-activiti-signal-intermediate-catch-event/10014/1 "2022-12-19T01:54:59Z")

</div>

Need to design a process flow such that it will be paused in the middle(after certain usertask) until a external event/process completes and then resumes the flow.

I have chosen to use “ **Signal intermediate catch event** ” with signal **scope=processinstance** (let me know if this is not the right option)…

Ideally the expectation is When the process arrives this stage it waits for external event to complete.

When the external event completes, I need to send signal to the process instance

**SignalIntermediateCatchEvent** → should consume the signal and continue the process.

Can any share the example java implementations of signal sending and consuming code .

New to the bpmn signal event usage, trying to find examples.

---

<div class="post-metadata">

**Author:** ![amporsim](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@amporsim](https://forum.flowable.org/u/amporsim)\
**Post date:** [December 19, 2022, 9:53am UTC](https://forum.flowable.org/t/how-to-implement-activiti-signal-intermediate-catch-event/10014/2 "2022-12-19T09:53:01Z")

</div>

Hi @kdevineni

To send the signal event you can use the `RuntimeService`:

```auto
private RuntimeService runtimeService;

Execution execution = runtimeService.createExecutionQuery().processInstanceId("your process instance id").signalEventSubscriptionName("Name of the Signal").singleResult();
runtimeService.signalEventReceived("Name of the Signal", execution.getId());

```

The signal can be catched by the [Signal Intermediate Catching Event](https://www.flowable.com/open-source/docs/bpmn/ch07b-BPMN-Constructs/#signal-intermediate-catching-event) within a process.

Regards,  
Simon

---

<div class="post-metadata">

**Author:** ![kdevineni](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/kdevineni/32/35_2.png) [@kdevineni](https://forum.flowable.org/u/kdevineni)\
**Post date:** [December 19, 2022, 11:47pm UTC](https://forum.flowable.org/t/how-to-implement-activiti-signal-intermediate-catch-event/10014/3 "2022-12-19T23:47:51Z")

</div>

Thanks @amporsim .

When I try to send the signal , I receive this error

> Execution ‘5250024’ has not subscribed to a signal event with name ‘resumeFlow’.

Assuming something needs to be done before the the send signal is issued.

Attaching my signal test flow below. Has two user tasks with intermediateCatchEvent(for signal resumeFlow) in the middle.  
I have the start and end listeners configured to just print the details.

When I start the workflow and approve the usertask1, workflow arriving signalintermediatecatchevent1.

From rest end point I am triggering the executing the send signal code, and I see the execution not subscribed to a signal message…

I am missing the step of subscribing to the signal , can you advice me on how this should be done.

```auto
<?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" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <signal id="resumeFlow" name="resumeFlow" activiti:scope="processInstance"></signal>
  <process id="myProcess" name="My process" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <userTask id="usertask1" name="Task1"></userTask>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
    <intermediateCatchEvent id="signalintermediatecatchevent1" name="SignalCatchEvent">
      <extensionElements>
        <activiti:executionListener event="end" class="com.imagework.flowable.listeners.doccs.SignalEndExecutionListener"></activiti:executionListener>
        <activiti:executionListener event="start" class="com.imagework.flowable.listeners.doccs.SignalStartExecutionListener"></activiti:executionListener>
      </extensionElements>
      <signalEventDefinition signalRef="resumeFlow"></signalEventDefinition>
    </intermediateCatchEvent>
    <sequenceFlow id="flow2" sourceRef="usertask1" targetRef="signalintermediatecatchevent1"></sequenceFlow>
    <userTask id="usertask2" name="User Task"></userTask>
    <sequenceFlow id="flow3" sourceRef="signalintermediatecatchevent1" targetRef="usertask2"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow4" sourceRef="usertask2" targetRef="endevent1"></sequenceFlow>
  </process>
 
</definitions>

```

---

<div class="post-metadata">

**Author:** ![kdevineni](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/kdevineni/32/35_2.png) [@kdevineni](https://forum.flowable.org/u/kdevineni)\
**Post date:** [December 20, 2022, 10:08am UTC](https://forum.flowable.org/t/how-to-implement-activiti-signal-intermediate-catch-event/10014/4 "2022-12-20T10:08:51Z")

</div>

> [@amporsim](#):
>
> `runtimeService.signalEventReceived("Name of the Signal", execution.getId());`

I am playing around this I tried with processInstanceId and executionId without any luck.

runtimeService.signalEventReceived(“Name of the Signal”, **processInstanceId** ); \>\> Execution ‘5250024’ has not subscribed to a signal event with name ‘resumeFlow’. \>\> this is not correct.

runtimeService.signalEventReceived(“Name of the Signal”, **execution.getId()**); \>\> code runs without errors, but signalintermediatecatchevent1 doesn’t receive the event/trigger. \>\> I am missing something here.

I tried the below case, when I have **signalintermediatecatchevent** created(& waiting), if the **signalintermediatethrowevent** is fired by completing Task1, then the **signalintermediatecatchevent** is picking up the event.

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/flowable/original/2X/d/d7e08f5948fe509a4912e10ecf65b5cbd448e9f6.png)

I am not sure what I am missing here for signal triggering., please advice

---

<div class="post-metadata">

**Author:** ![amporsim](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@amporsim](https://forum.flowable.org/u/amporsim)\
**Post date:** [December 20, 2022, 3:49pm UTC](https://forum.flowable.org/t/how-to-implement-activiti-signal-intermediate-catch-event/10014/5 "2022-12-20T15:49:32Z")

</div>

Hi @kdevineni

If you change the signal scope from `processInstance` to `global` it should work.

`<signal id="resumeFlow" name="resumeFlow" activiti:scope="global"></signal>`

Test case:

```auto
    @Test
    public void test(){
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProcess");

        Task task = taskService.createTaskQuery().taskDefinitionKey("usertask1").processInstanceId(processInstance.getProcessInstanceId()).singleResult();
        taskService.complete(task.getId());

        Execution execution = runtimeService.createExecutionQuery()
                .processInstanceId(processInstance.getProcessInstanceId())
                .signalEventSubscriptionName("resumeFlow")
                .singleResult();
        runtimeService.signalEventReceived("resumeFlow", execution.getId());

        assertThat(taskService.createTaskQuery().taskDefinitionKey("usertask2").processInstanceId(processInstance.getProcessInstanceId()).singleResult())
                .isNotNull();
    }

```

Regards,  
Simon

---

<div class="post-metadata">

**Author:** ![kdevineni](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/kdevineni/32/35_2.png) [@kdevineni](https://forum.flowable.org/u/kdevineni)\
**Post date:** [December 21, 2022, 12:05pm UTC](https://forum.flowable.org/t/how-to-implement-activiti-signal-intermediate-catch-event/10014/6 "2022-12-21T12:05:53Z")

</div>

@amporsim Thank you .  
Changing scope from processinstance to global worked.
