cancel
Showing results for 
Search instead for 
Did you mean: 

Signal not received by engine

andrey_nikolov
Champ in-the-making
Champ in-the-making
I am trying to implement a signal within the process instance to receive some data and then continue the execution with Activiti 5.21.

The process definition defines the signal under definitions element.
   <signal id="Process_Signal" name="Process Signal" activiti:scope="processInstance"/>

The catch node is defined under process element.
   <intermediateCatchEvent id="Receive_Vacation_Balance" name="Receive Vacation Balance">
      <signalEventDefinition signalRef="Process_Signal"/>
   </intermediateCatchEvent>

After deployment, we can see the signal is registered in ACT_RU_EVENT_SUBSCR table.
   EVENT_TYPE = 'signal', EVENT_NAME = 'Process Signal', EXECUTION_ID = '12', PROC_INST_ID = '6', ACTIVITY_ID = 'Receive_Vacation_Balance'

After the process gets instantiated, the control stops at the catch node and awaits the signal as expected. Then programmatically sending the signal by name and execution ID, but cannot see the engine receiving it and passing it to the process instance.
   runtimeService.signalEventReceived("Process Signal", 12, VariablesMap)

What could be wrong? Are we missing something?
7 REPLIES 7

andrey_nikolov
Champ in-the-making
Champ in-the-making
I have observed that sending a signal with name and execution ID does NOT work.
<code>
runtimeService.signalEventReceived("Process Signal", 12, VariablesMap)
</code>

However, sending the signal with execution ID only works.
<code>
runtimeService.signal(12, VariablesMap)
</code>

What is the difference between 'signal' and 'signalEventReceived' API? Could it be a bug or broken functionality in Activiti 5.21?

andrey_nikolov
Champ in-the-making
Champ in-the-making
The process definition defines the signal under definitions element.
<code>
<signal id="Process_Signal" name="Process Signal" activiti:scope="processInstance"/>
</code>
The catch node is defined under process element.
<code>
<intermediateCatchEvent id="Receive_Vacation_Balance" name="Receive Vacation Balance">
  <signalEventDefinition signalRef="Process_Signal"/>
</intermediateCatchEvent>
</code>

andrey_nikolov
Champ in-the-making
Champ in-the-making
Please advise: what is the difference between 'signal' and 'signalEventReceived' API?

Is there an corresponding API to allow raising a signal by name? Perhaps something like 
<code>
signal(signalName, execitionId, variablesMap)
</code>
We need to pass a signal to the engine and specify its name, so that within Activiti Listener we can distinguish which signal has been caught.

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Andrey,


  /**
   * Notifies the process engine that a signal event of name 'signalName' has been received. This method delivers the signal to all executions waiting on the signal.
   * <p/>
   *
   * <strong>NOTE:</strong> The waiting executions are notified synchronously.
   *
   * @param signalName
   *          the name of the signal event
   */
  void signalEventReceived(String signalName);


  /**
   * Sends an external trigger to an activity instance that is waiting inside
   * the given execution.
   *
   * @param executionId
   *          id of execution to signal, cannot be null.
   * @throws ActivitiObjectNotFoundException
   *           when no execution is found for the given executionId.
   */
  void signal(String executionId);

The difference is that signal(String executionId) triggers execution. signalEventReceived(String signalName) sends a signal. It means that when some execution waits on the signal, signal is received and waiting execution is triggered.
You can create jUnit test to reproduce your issue.
https://forums.activiti.org/content/sticky-how-write-unit-test

Regards
Martin

andrey_nikolov
Champ in-the-making
Champ in-the-making
Hi Martin,

Thank you for your response!

Based on the API description, 'signalEventReceived' provides exactly the functionality we need: programmatically send a signal to Activiti engine.
<code>
Notifies the process engine that a signal event of name 'signalName' has been received. This method delivers the signal to all executions waiting on the signal. The waiting executions are notified synchronously.
</code>

The problem we have is that the signal is NOT actually caught by the engine and the process instance remains stuck at the 'intermediateCatchEvent'.

How could we check if the signal is received by the engine and properly correlated to the active instance? Do we need any special engine configuration to enable signal processing?

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Andrey,

As I said, create jUnit test
(https://forums.activiti.org/content/sticky-how-write-unit-test) and add link to your git hub fork. Then it will be easy to solve something.


Regards
Martin

martin_grofcik
Confirmed Champ
Confirmed Champ
Andrey,

You can have a look on
org.activiti.engine.test.bpmn.event.signal.SignalEventTest#testSignalCatchIntermediate
in activiti source - working signals example.

Regards
Martin