cancel
Showing results for 
Search instead for 
Did you mean: 

Signal Boundary Event

Not applicable
Hi All,

I'm using Activiti 5.9 and either I've misunderstood how a Signal Boundary Event works, or they don't seem to be working.

This is the test process I've put together:
[img]http://i.imgur.com/8UIeJ.jpg[/img]

When a process starts the execution arrives at "Receive Task" and waits for it's signal. If
runtimeService.signal(executionId);
is invoked the execution continues down the "Normal Path" and ends at it's end state.

What I was expecting was that if instead of calling
runtimeService.signal(executionId);
I call
runtimeService.signalEventReceived("TheSignal");
(that's the signal ID specified on the Boundary Signal Event) when the execution was waiting at "Receive Task" that would make it take the "Signal Path" and end at it's end event. Instead it appears to have no effect on the execution (the "Signal Path" is never taken and I can subsequently call signal(executionId) and the normal path is taken).

The "Receive Task" and boundary event definitions are as follows:

<receiveTask id="receiveTask" name="Receive Task"></receiveTask>
<boundaryEvent id="boundarysignal1" name="" cancelActivity="true" attachedToRef="receiveTask">
  <signalEventDefinition signalRef="TheSignal"></signalEventDefinition>
</boundaryEvent>
and "TheSignal" is defined at the top level definitions.

I just noticed something else. If I call:
runtimeService.signalEventReceived("TheSignal", executionId);
I get the error message: "org.activiti.engine.ActivitiException: Execution '22' has not subscribed to a signal event with name 'TheSignal'."

I have verified that the execution is waiting at the "Receive Task".

If anyone could let me know what I am doing wrong or whether there is actually a bug given the described behaviour that would be sincerely appreciated. There doesn't appear to be any examples that include a signal in the 5.9 distribution.

Regards,
Nick T
8 REPLIES 8

jcavezian
Champ in-the-making
Champ in-the-making
Hello Nick,

maybe I'm wrong, but as you didnot mention it,
did you declare the signal itself ?

User guide says here : "The attribute signalRef references a signal element declared as a child element of the definitions root element."

<definitions… >
        <!– declaration of the signal –>
        <signal id="TheSignal" name="The signal" />

Hope this helps, regards,
Jérôme

Not applicable
Hi Jerome,

Thanks for the reply. The signal is declared as you mentioned. That's what I meant by:
and "TheSignal" is defined at the top level definitions
Apologies for any confusion.

Thanks,
Nick

jayehsea
Champ in-the-making
Champ in-the-making
I am having the same issue. I am getting an ActivitiException with the message "Execution '18812' has not subscribed to a signal event with name 'MySignal'."

The line of code leading to this exception is:

runtimeService.signalEventReceived("MySignal", exec.getId());


My process definition contains:


<definitions xmlns=…">

    <signal id="MySignal" name="My Signal" />
   
  <process id="VaultingMonitorAndFollowup" name="Vaulting Monitor And Follow Up">
    <startEvent id="startevent1" name="Start" activiti:initiator="initiator"></startEvent>
    <userTask id="waitForCertificate" name="Certificate Monitor Task" activiti:candidateGroups="accountancy"></userTask>
    <boundaryEvent id="vaultEscalationTimer" cancelActivity="true" attachedToRef="waitForCertificate">
      <timerEventDefinition>
        <timeDuration>${vaultDuration}</timeDuration>
      </timerEventDefinition>
    </boundaryEvent>
<boundaryEvent id="boundaryCancelSignal" attachedToRef="waitForCertificate" cancelActivity="true">
  <signalEventDefinition signalRef="MySignal" />
</boundaryEvent>



I have not been able to find any other documentation saying how a process or task should "subscribe" to a signal. I look forward to learning how to do this.

Thanks.
Jim

trademak
Star Contributor
Star Contributor
Hi,

There are a couple of things to pay attention to when using the signal event functionality.
First when you want to use the runtimeService.signalEventReceived method you should pass-in the signal name and not the id.
So when you have the following signal definition:

<signal id="testSignal" name="Test signal"/>
You should use Test signal in the runtimeService.signalEventReceived method.
When you want to use the runtimeService.signalEventReceived method with the execution id parameter you should make sure that this is the execution id of the signal.
You can query the runtimeService to get this signal execution like this:

Execution execution = runtimeService.createExecutionQuery().signalEventSubscription("Test signal").singleResult();
Again make sure that you use the signal name.
Hope this helps you to get your example working.

Best regards,

Not applicable
Hi Tijs,

That was the problem, I was using the signal ID instead of the name. Thanks for the assistance Smiley Happy

Cheers,
Nick

venkatesh
Champ in-the-making
Champ in-the-making
Hi,

I am pretty new to activiti. So, Practicing some test cases for easy understanding. Can Any One help me with the sample bpmn & Junit test file for  : Signal Catch & Throw. Further explanation about the concept would be usefull as well.
Thanks in advance.

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

  • download activiti source
  • go to org.activiti.engine.test.bpmn.event.signal.SignalEventTest
Regards
Martin

venkatesh
Champ in-the-making
Champ in-the-making
Hi martin,

Thank You so much for the help.

Regards,
Venkatesh.